回复 1# 的帖子
这是我做一个例子:你可以参考一下.
Dim conn As New SqlClient.SqlConnection
Dim cmd As New SqlClient.SqlCommand
Dim myadp As New SqlClient.SqlDataAdapter
Dim dsl As DataSet = New DataSet
Dim mytable As New DataTable
conn.ConnectionString = "data source=" & () & ";database=hotel;user id=sa;password="
cmd.Connection = conn
Try
conn.Open()
= "select *(全部内容,也可以搜索你要的字段) from users(数据表名) where u='" + TextBox1.Text + "'"(数据表中的字段U要与你输入的文本相同)
myadp.SelectCommand = cmd
myadp.Fill(dsl, "area")
mytable = dsl.Tables("area")
TextBox2.Text = mytable.Rows(0)("realname")
TextBox3.Text = mytable.Rows(0)("sfz")
Catch ex As Exception
Response.Write(" <script language=javascript>window.alert('数据库操作错误!!');</script>")
Finally
conn.Close()
End Try