用VS2010中获取数据库字段的值怎么写语句?
请大神帮忙指点一下id=表的id表达式用vb怎么写?代码如下:PrivateSubbtnOk_Click(ByValsenderAsSystem.Object,ByVal...
请 大神帮忙 指点一下 id= 表的id 表达式用vb怎么写?
代码如下:
Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
Dim id As Integer
Dim sqlConnection1 As SqlClient.SqlConnection
sqlConnection1 = New System.Data.SqlClient.SqlConnection(sqlConnect)
sqlConnection1.Open()
Dim sql As String = "select count(*) from View_Users where Users_Name='" & txtUserName.Text.Trim() & "' and Password='" & MD5(LTrim(RTrim(txtPassword.Text())), 32) & "'"
Dim sqlCmd As SqlCommand = New SqlCommand(sql, sqlConnection1)
Dim count As Integer
count = sqlCmd.ExecuteScalar
If count > 0 Then
id = 数据库 表 id字段的值 '这个地方不会写表达式
main.Show()
Me.Hide()
Else
TextBox1.Text = MD5(LTrim(RTrim(txtPassword.Text())), 32)
txtPassword.Text = ""
End If
sqlConnection1.Close()
End Sub 展开
代码如下:
Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
Dim id As Integer
Dim sqlConnection1 As SqlClient.SqlConnection
sqlConnection1 = New System.Data.SqlClient.SqlConnection(sqlConnect)
sqlConnection1.Open()
Dim sql As String = "select count(*) from View_Users where Users_Name='" & txtUserName.Text.Trim() & "' and Password='" & MD5(LTrim(RTrim(txtPassword.Text())), 32) & "'"
Dim sqlCmd As SqlCommand = New SqlCommand(sql, sqlConnection1)
Dim count As Integer
count = sqlCmd.ExecuteScalar
If count > 0 Then
id = 数据库 表 id字段的值 '这个地方不会写表达式
main.Show()
Me.Hide()
Else
TextBox1.Text = MD5(LTrim(RTrim(txtPassword.Text())), 32)
txtPassword.Text = ""
End If
sqlConnection1.Close()
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询