vb.net和SQL server数据库连接时的问题
这是代码:mm=dr.GetString(0)这句出现问题.运行不下去,说是没有返回值“System.InvalidOperationException”类型的未经处理的...
这是代码: mm = dr.GetString(0)这句出现问题.运行不下去,说是没有返回值
“System.InvalidOperationException”类型的未经处理的异常在 System.Data.dll 中发生 这是VS提醒的
Private Sub database()
Dim mm As String
Dim sql As String = "select * from work where name='" & Trim(TextBox1.Text) & "'and id='" & Trim(TextBox2.Text) & "'"
Dim sqlconnection1 As SqlClient.SqlConnection
Dim strconnect As String = "data source=PC-201412161909;initial catalog=manager;user id=sa;password=1lovejesus;"
sqlconnection1 = New SqlConnection(strconnect)
sqlconnection1.Open()
Dim com As SqlCommand = New SqlCommand(sql, sqlconnection1)
Dim dr As SqlDataReader = com.ExecuteReader
dr.Read()
mm = dr.GetString(0)
If mm = TextBox3.Text Then
main.Show()
Else
MsgBox("密码不对请重新输入!!!")
TextBox3.Clear()
TextBox3.Focus()
End If
sqlconnection1.Close()
End Sub
End Class 展开
“System.InvalidOperationException”类型的未经处理的异常在 System.Data.dll 中发生 这是VS提醒的
Private Sub database()
Dim mm As String
Dim sql As String = "select * from work where name='" & Trim(TextBox1.Text) & "'and id='" & Trim(TextBox2.Text) & "'"
Dim sqlconnection1 As SqlClient.SqlConnection
Dim strconnect As String = "data source=PC-201412161909;initial catalog=manager;user id=sa;password=1lovejesus;"
sqlconnection1 = New SqlConnection(strconnect)
sqlconnection1.Open()
Dim com As SqlCommand = New SqlCommand(sql, sqlconnection1)
Dim dr As SqlDataReader = com.ExecuteReader
dr.Read()
mm = dr.GetString(0)
If mm = TextBox3.Text Then
main.Show()
Else
MsgBox("密码不对请重新输入!!!")
TextBox3.Clear()
TextBox3.Focus()
End If
sqlconnection1.Close()
End Sub
End Class 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询