Web Developer
ASP.NET, Visual Basic.NET, C#, TSQL, HTML, CSS, PHP, JavaScript, WordPress, WooCommerce
Windows Server, Internet Information Server, SQL Server, Hyper-V

Вызов Stored Procedure с параметрами в SQL Server

Данный код вызывает хранимую процедуру с параметрами на Visual Basic.NET

Imports System.Data.SqlClient
Imports System.Data

...

Dim con As New SqlConnection
Dim cmd As New SqlCommand

Try
	With con
		.ConnectionString = ConfigurationManager.ConnectionStrings("dbConnectionString").ConnectionString
		.Open()
	End With

	With cmd
		.Connection = con
		.CommandText = "StoredProcedureName"
		.CommandType = CommandType.StoredProcedure

		.Parameters.Add("@ParamA", SqlDbType.NVarChar, 0).Value = "..."
		.Parameters.Add("@ParamB", SqlDbType.Int).Value = 1

		.ExecuteNonQuery()
	End With
Catch ex As Exception
	' обработка ошибок
Finally
	cmd.Dispose()
	con.Close()
End Try
Share

You may also like...

Добавить комментарий

Ваш адрес email не будет опубликован.