The classes you must use to connect to SQL Server
are called ADO.net
SQL Server and ADO.NET
to work with a Stored Procedure
you would basically use:
Dim dt As DataTabla = New DataTable()
Using conn As New SqlConnection("connectionstring")
Dim cmd As New SqlCommand("<storedprocedure>", conn)
cmd.CommandType = SqlCommandType.StoredProcedure
cmd.Parameters.AddWithValue("@param1", valor)
Dim da As New SqlDataAdapter(cmd)
da.Fill(dt)
End Using
In this case I would apply to make a select
since you load a datatable
with the records that returns, you define the name of procedure
, you assign the CommandType
of the object command
and you maintain parameters
To make a insert
or update
would be:
Dim dt As DataTabla = New DataTable()
Using conn As New SqlConnection("connectionstring")
Dim cmd As New SqlCommand("<storedprocedure>", conn)
cmd.CommandType = SqlCommandType.StoredProcedure
cmd.Parameters.AddWithValue("@param1", valor)
cmd.ExecuteNonQuery()
End Using
It's practically the same only that you execute it with the ExecuteNonQuery()