我想问你们所有关于网格视图选择的行将值从数据库传递到另一个页面。现在我的第二页捕获了例如detail.aspx?id=5
的id链接,但是在同一页面我还想显示id = 5的所有数据库。因为在第一页数据网格视图只显示3列,id,name和detail是数据库中的链接,id和名称。我现在对如何实施它一无所知,希望有人可以指导我。
' cr_number = Request.QueryString("id")
Label17.Text = cr_number
Using sqlConn As New MySqlConnection(strConnectionString)
sqlConn.Open()
Using sqlComm As New MySqlCommand()
sqlComm.Connection = sqlConn
With sqlComm
.CommandText = "select * From cr_record where cr_number=cr_number and Emplid=Emplid"
Try
Dim sqlReader As MySqlDataReader = sqlComm.ExecuteReader()
While sqlReader.Read()
Label1.Text = sqlReader("isu").ToString()
Label2.Text = sqlReader("Emplid").ToString()
Label3.Text = sqlReader("Nama").ToString()
Label4.Text = sqlReader("DeptDesc").ToString()
Label5.Text = sqlReader("JobDesc").ToString()
Label6.Text = sqlReader("LocDesc").ToString()
Label7.Text = sqlReader("email").ToString()
Label8.Text = sqlReader("pnum").ToString()
Label9.Text = sqlReader("change1").ToString()
Label10.Text = sqlReader("reasonchange").ToString()
Label11.Text = sqlReader("problem").ToString()
Label12.Text = sqlReader("priority").ToString()
Label13.Text = sqlReader("reasondescription").ToString()
Label14.Text = sqlReader("systemrequest").ToString()
Label15.Text = sqlReader("Status").ToString()
Label16.Text = sqlReader("date1").ToString()
End While
Catch ex As MySqlException
MessageBox.Show(ex.Message)
End Try
sqlConn.Close()
End With
End Using
End Using'
这是我最新的代码@damit
答案 0 :(得分:0)
您需要使用CommandText
值构建QueryString
,如下所示
.CommandText = "select * From cr_record where Emplid=" & Request.QueryString["Emplid"]
最佳选择是使用参数
.CommandText = "select * From cr_record where Emplid=@Emplid"
.Parameters.AddWithValue("@Emplid", Request.QueryString["Emplid"]);