Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности

Новые сообщения [новые:0]
Дайджест
Горячие темы
Избранное [новые:0]
Форумы
Пользователи
Статистика
Статистика нагрузки
Мод. лог
Поиск
|
|
24.04.2013, 11:41
|
|||
|---|---|---|---|
|
|||
Выполнение хранимых процедур SQL Server 2005 в ASP.NET (Visual Studio 2012) |
|||
|
#18+
Есть хранимая процедура на сервере: USE [ReportsPodrSQL] GO /****** Объект: StoredProcedure [dbo].[GetProba] Дата сценария: 04/24/2013 11:30:40 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= ALTER PROCEDURE [dbo].[GetProba] (@param1 int = 400401,@RowCount int output) as BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. -- SET NOCOUNT ON; select * from ubytki where codepodr=@param1 -- Insert statements for procedure here SELECT @RowCount=@@ROWCOUNT END RETURN В среде Microsift Sql Server Management Studio Express работает прекрасно, а вот из Visual Studio 2012 не могу запустить никак. Пробовал так: Private Sub btnGetAuthors_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnGetAuthors.Click Dim DS As DataSet Dim MyConnection As SqlConnection Dim MyDataAdapter As SqlDataAdapter 'Create a connection to the SQL Server. MyConnection = New SqlConnection("server=(local);database=pubs;Trusted_Connection=yes") 'Create a DataAdapter, and then provide the name of the stored procedure. MyDataAdapter = New SqlDataAdapter("GetProba", MyConnection) 'Set the command type as StoredProcedure. MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure ' 'Create and add a parameter to Parameters collection for the stored procedure. MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@param1", _ SqlDbType.Int, 8)) ' 'Assign the search value to the parameter. MyDataAdapter.SelectCommand.Parameters("@param1").Value = 400401 'Create and add an output parameter to Parameters collection. MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@RowCount", _ SqlDbType.Int)) 'Set the direction for the parameter. This parameter returns the Rows returned. MyDataAdapter.SelectCommand.Parameters("@RowCount").Direction = ParameterDirection.Output DS = New DataSet() 'Create a new DataSet to hold the records. MyDataAdapter.Fill(DS, "UBY") 'Fill the DataSet with the rows returned. 'Get the number of rows returned, and then assign it to the Label control. lblRowCount.Text = DS.Tables(0).Rows.Count().ToString() & " Rows Found!" lblRowCount.Text = MyDataAdapter.SelectCommand.Parameters(1).Value 'Set the data source for the DataGrid as the DataSet that holds the rows. GrdAuthors.DataSource = DS.Tables("UBY").DefaultView 'Bind the DataSet to the DataGrid. 'NOTE: If you do not call this method, the DataGrid is not displayed! Grdauthors.DataBind() MyDataAdapter.Dispose() 'Dispose of the DataAdapter. MyConnection.Close() 'Close the connection. End Sub Этот пример взят из MSDN. Все вроде должно работать. И пробовал чепрез сервис работы с базами данных среды Microsoft Visual Studio 2012. Обращение к хранимой процедуре есть, но почему то не выполняется SELECT и не возвращаются параметры. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
24.04.2013, 11:49
|
|||
|---|---|---|---|
|
|||
Выполнение хранимых процедур SQL Server 2005 в ASP.NET (Visual Studio 2012) |
|||
|
#18+
А причем тут ASP.NET? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
24.04.2013, 13:32
|
|||
|---|---|---|---|
|
|||
Выполнение хранимых процедур SQL Server 2005 в ASP.NET (Visual Studio 2012) |
|||
|
#18+
http://stackoverflow.com/questions/3309213/getting-return-value-from-stored-procedure-in-ado-net --Все вроде должно работать. ну да если уметь готовить ссыль на мснд дали бы чтоб поглядеть ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
24.04.2013, 13:41
|
|||
|---|---|---|---|
|
|||
Выполнение хранимых процедур SQL Server 2005 в ASP.NET (Visual Studio 2012) |
|||
|
#18+
handmadeFromRu http://stackoverflow.com/questions/3309213/getting-return-value-from-stored-procedure-in-ado-net --Все вроде должно работать. ну да если уметь готовить ссыль на мснд дали бы чтоб поглядеть Вот ссылка: http://support.microsoft.com/kb/306574 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
24.04.2013, 14:38
|
|||
|---|---|---|---|
|
|||
Выполнение хранимых процедур SQL Server 2005 в ASP.NET (Visual Studio 2012) |
|||
|
#18+
о черт и это мс опубликовала....нда. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
25.04.2013, 11:18
|
|||
|---|---|---|---|
|
|||
Выполнение хранимых процедур SQL Server 2005 в ASP.NET (Visual Studio 2012) |
|||
|
#18+
handmadeFromRu, Заработало вот так: Private Sub btnGetAuthors_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnGetAuthors.Click Dim DS As DataSet Dim MyConnection As SqlConnection Dim ReturnValue As SqlParameter Dim cmd As SqlCommand 'Create a connection to the SQL Server. MyConnection = New SqlConnection("server=MSLN-KRAFT\SQL2005D;database=ReportsPodrSQL;Trusted_Connection=yes") cmd = New SqlCommand("GetProba", MyConnection) cmd.CommandType = CommandType.StoredProcedure ReturnValue = New SqlParameter("@RowCount", SqlDbType.Int) ReturnValue.Direction = System.Data.ParameterDirection.Output cmd.Parameters.Add(ReturnValue) MyConnection.Open() cmd.ExecuteNonQuery() Alert(cmd.Parameters("@RowCount").Value) end sub ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
25.04.2013, 11:50
|
|||
|---|---|---|---|
|
|||
Выполнение хранимых процедур SQL Server 2005 в ASP.NET (Visual Studio 2012) |
|||
|
#18+
Так тоже заработало: Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim DS As DataSet Dim MyConnection As SqlConnection Dim MyDataAdapter As SqlDataAdapter 'Create a connection to the SQL Server. MyConnection = New SqlConnection("server=MSLN-KRAFT\SQL2005D;database=ReportsPodrSQL;Trusted_Connection=yes") 'Create a DataAdapter, and then provide the name of the stored procedure. MyDataAdapter = New SqlDataAdapter("GetProba", MyConnection) 'Set the command type as StoredProcedure. MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure 'Create and add a parameter to Parameters collection for the stored procedure. 'Create and add an output parameter to Parameters collection. MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@RowCount", _ SqlDbType.Int, 4)) 'Set the direction for the parameter. This parameter returns the Rows returned. MyDataAdapter.SelectCommand.Parameters("@RowCount").Direction = ParameterDirection.Output DS = New DataSet() 'Create a new DataSet to hold the records. MyDataAdapter.Fill(DS, "AuthorsByLastName") 'Fill the DataSet with the rows returned. 'Get the number of rows returned, and then assign it to the Label control. 'lblRowCount.Text = DS.Tables(0).Rows.Count().ToString() & " Rows Found!" lblRowCount.Text = MyDataAdapter.SelectCommand.Parameters(0).Value & " Rows Found!" 'Set the data source for the DataGrid as the DataSet that holds the rows. GrdAuthors.DataSource = DS.Tables("AuthorsByLastName").DefaultView 'Bind the DataSet to the DataGrid. 'NOTE: If you do not call this method, the DataGrid is not displayed! GrdAuthors.DataBind() MyDataAdapter.Dispose() 'Dispose of the DataAdapter. MyConnection.Close() 'Close the connection. End Sub ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|

start [/forum/topic.php?fid=18&mobile=1&tid=1358513]: |
0ms |
get settings: |
10ms |
get forum list: |
22ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
57ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
54ms |
get tp. blocked users: |
2ms |
| others: | 247ms |
| total: | 413ms |

| 0 / 0 |
