I have facing this problem, and i don't know what is going wrong.
The SP when tested in the Query Analyser works fine.
the resultant is either a 0 or PID where 0 is returned when the insert doesn't happen
I might have some extra declaration, which might be causing this error , or not defining the right thing.
Any suggestion is welcomed and greatly appreciated.
Thanks
Is PID a return value, or an output parameter? You should use an output parameter to return an ident from a sproc.
Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
Dim sSQLConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim daInsertSku As SqlDataAdapter = New SqlDataAdapter()
Try
sSQLConnection.Open()
Dim cmdInsert As New SqlCommand("sp_request", sSQLConnection)
cmdInsert.CommandType = CommandType.StoredProcedurecmdInsert.Parameters.Add("@.Username", SqlDbType.Int, 4)
cmdInsert.Parameters("@.Username").Value = "0"Dim PID As SqlParameter = New SqlParameter("@.identity", SqlDbType.Int)
PID.Direction = ParameterDirection.ReturnValue
cmdInsert.Parameters.Add(PID)daInsertSku.InsertCommand = cmdInsert
cmdInsert.ExecuteNonQuery()
Response.Write(PID.Value)Catch Exc As Exception
' error handling
Finally
' close connection
End Try
End Sub
And what is wrong? Are you getting an error?|||I did get it working, i changed to Output Parameter instead or Return
thank yousql
No comments:
Post a Comment