0
我可以在如何从数据库检索记录的工作示例中选择下拉列表后填充相关文本框。我有什么是绝对不工作&即时通讯工作VS 2008。任何人都可以告诉我的方式?从下拉列表中选择后,从SQL查询中填充文本框
我有:
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()
就是这样!非常感谢! :) – brainsfrying 2012-01-01 08:05:39