May i have a working sample on how to retrieve records from a DB & populate the relevant textboxes after a selection at a dropdownlist. What i have is definitely not working & im working on VS 2008. Can anyone show me the way?
What i have:
Dim myConn As New SqlConnection
Dim myCmd As New SqlCommand
Dim dtrReader As SqlDataReader
myConn.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
myCmd = myConn.CreateCommand
myCmd.CommandText = "SELECT * FROM Product WHERE product_id = '" & DropDownList2.Text & "'"
'myCmd.CommandType = CommandType.Text
'populate controls from DB
'myCmd.Parameters.Add(New SqlParameter("@product_id", a))
myCmd.Parameters.Add(New SqlParameter("@product_name", (txtProductName2.Text)))
myCmd.Parameters.Add(New SqlParameter("@product_title", txtProductTitle2.Text))
myCmd.Parameters.Add(New SqlParameter("@product_desc", txtProductDescription2.Text))
myCmd.Parameters.Add(New SqlParameter("@product_author", txtProductAuthor2.Text))
mycmd.Dispose()
myConn.Close()
myConn.Dispose()