主题:新手请教关于DataSet查询的问题!急!急!急!
请高手指教!如何在DataSet中已知某记录的值,如何得到其对应的ID号?
表名:myTab,字段:Id,Name,数据库连接字符串:ConnStr, VB.Net代码如下:
Dim ConnString As String = ConfigurationSettings.AppSettings("ConnStr")
Dim Conn As SqlClient.SqlConnection = New SqlClient.SqlConnection(ConnString)
Dim SQLAdp As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter
Dim DataSet As DataSet = New DataSet
Dim CmdTxt As String = "Select Id,Name From myTab"
Dim TabName As String = "myTab"
SQLAdp.SelectCommand = New SqlClient.SqlCommand(CmdText, Conn)
Conn.Open()
SQLAdp.Fill(DataSet, TabName)
Conn.Close()
Dim strName As String = me.TextBox1.Text '值为"张三"
Dim DT As DataTable = DataSet.Tables(TabName)
Dim SR As DataRow
MsgTxt = DataSet.Tables(TabName).Select("Name='strName'").IndexOf '到这一句就做不下去了!
MsgBox(MsgTxt)
急!急!急!
表名:myTab,字段:Id,Name,数据库连接字符串:ConnStr, VB.Net代码如下:
Dim ConnString As String = ConfigurationSettings.AppSettings("ConnStr")
Dim Conn As SqlClient.SqlConnection = New SqlClient.SqlConnection(ConnString)
Dim SQLAdp As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter
Dim DataSet As DataSet = New DataSet
Dim CmdTxt As String = "Select Id,Name From myTab"
Dim TabName As String = "myTab"
SQLAdp.SelectCommand = New SqlClient.SqlCommand(CmdText, Conn)
Conn.Open()
SQLAdp.Fill(DataSet, TabName)
Conn.Close()
Dim strName As String = me.TextBox1.Text '值为"张三"
Dim DT As DataTable = DataSet.Tables(TabName)
Dim SR As DataRow
MsgTxt = DataSet.Tables(TabName).Select("Name='strName'").IndexOf '到这一句就做不下去了!
MsgBox(MsgTxt)
急!急!急!