开发者

How to catch result set in code view

开发者 https://www.devze.com 2023-02-15 12:25 出处:网络
I created this stored procedure. CREATE PROCEDURE PersonAssign ( @PersonID int ) BEGIN Update Register set Status = \'开发者_开发技巧true\' where PersonID = @PersonID;

I created this stored procedure.

CREATE PROCEDURE PersonAssign
(
    @PersonID int
)
BEGIN
    Update Register set Status = '开发者_开发技巧true' where PersonID = @PersonID;
    SELECT * FROM Register
END

Now, I want to get result set in vb.net by using ADO.net. How can I catch this. Please help me.


I would probably create a sqlcommand object, connect to the database, executeReader and return a sqldatareader object. There a bunch of other ways to do this depending on what you want to do with the data. Please be more specific if you aren't looking for a general idea.


Try

 Dim con As New SqlConnection
 Dim cmd As New SqlCommand
 Dim dr As New SqlDataReader()
 Try
  con.ConnectionString = Settings.ConnectionString
  con.Open()
  cmd.Connection = con
  cmd.CommandType = CommandType.StoredProcedure
  cmd.CommandText = "PersonAssign"
  cmd.Parameters.Add("@PersonID", SqlDbType.Int)
  cmd.Parameters("@PersonID").Value = -Parameter-value-
  dr = cmd.ExecuteReader()

  ' Do something with dr
Catch e As Exception
End Try
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号