How to assign parameter value to Stored procedure from the form in vb.net ?
-
Dir sir I created a stored procedure that consist of parameter field in SQL server 2000 and I want to execute it from vb.net interface,but i don't know how to assign parameter value. Can you tell me about solutions in the above topic ? Thank you in advance. Best regard, saravuth
-
Dir sir I created a stored procedure that consist of parameter field in SQL server 2000 and I want to execute it from vb.net interface,but i don't know how to assign parameter value. Can you tell me about solutions in the above topic ? Thank you in advance. Best regard, saravuth
Dim sqlConn as new sqlClient.Connection(your connection string here) Dim sqlCmd as new sqlClient.sqlCommand() sqlCmd.Connection = sqlConn sqlCmd.CommandType = CommandType.StoredProcedure sqlCmd.CommandText = "your stored procedure name here" Dim spParameter As New SqlClient.SqlParameter() With spParameter .ParameterName = "your parameter name e.g. @CompanyId" .Size = Size .SqlDbType = e.g. NVarChar (SqlDbType) .Direction = e.g. Input (System.Data.ParameterDirection) .IsNullable = True/False .Value = Your input value End With sqlCmd..Parameters.Add(spParameter) sqlCmd.Execute to retrieve return values : sqlCmd.UpdatedRowSource = UpdateRowSource.OutputParameters Dim myCompanyId = sqlCmd.Parameters.Item("CompanyId").Value Steve Jowett