Does anyone know how to call a SQL store procedure that return a value to the page?
I've a simple data entry aspx page with several textboxes and a save button. When user fill out the form and click save/submit, it calls a store procedure to insert a row into a SQL table and automatically generate an ID that need to return the the page to display for the user.
Are there a similar article somewhere?
Thank you all!
check out the docs about using ExecuteScalar() Method.|||Using ExecuteScalar() requires a separate procedure call. I would like to use the same procedure call that to insert a record into a table and also return an ID back. My store procedure look like this:
sqlString = "EXEC spInsertRow 'parm1','parm2','parm3', @.ReturnID OUTPUT"
Thanks
|||In the end of your sproc:
SELECT @.ReturnID = @.@.IDENTITY
|||I suggested ExecuteScalar assuming you are doing some insert and want to return the ID.
If that is not the case you can use the OUTPUT parameters..
Dim res as integer
myParam = mycommand.CreateParameter()
myParam.ParameterName = "@.returnId"
myParam.Direction = ParameterDirection.Output
myParam.SqlDbType = SqlDbType.bigint
mycommand.Parameters.Add(myParam)
res = mycommand.Parameters("@.result").Value
|||
Thank you. It works
|||Can you share your general procedure. I'm having the same issue and have tested many ways. Still not working.
See posthttp://forums.asp.net/1178243/ShowPost.aspx
Thanks
No comments:
Post a Comment