Posted By

delineo on 11/12/10


Tagged

database stored procedure connection datareader


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

d_modugno


DataReader code block


 / Published in: VB.NET
 

  1. Using myConnection As New SqlConnection
  2. myConnection.ConnectionString = ConfigurationManager.ConnectionStrings("strConn").ConnectionString
  3.  
  4. Dim myCommand As New SqlCommand
  5. myCommand.Connection = myConnection
  6. myCommand.CommandText = "spSelect"
  7. myCommand.CommandType = CommandType.StoredProcedure
  8. myCommand.Parameters.AddWithValue("@User", ViewState("User").toString())
  9.  
  10. myConnection.Open()
  11. Using dtrReader As SqlDataReader = myCommand.ExecuteReader()
  12. While dtrReader.Read()
  13.  
  14. strLink = dtrReader("Title")
  15.  
  16. End While
  17. End Using
  18. myConnection.Close()
  19.  
  20. End Using

Report this snippet  

You need to login to post a comment.