未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 system.data.dll 中。
我用VB.net2003写的登陆界面代码:PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSyste...
我用VB.net2003写的登陆界面代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Total As Integer
Dim StrConnApp = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & "setting.mdb"
Dim ConnTemp As New OleDb.OleDbConnection
Dim StrSQL As String
ConnTemp.ConnectionString = StrConnApp
StrSQL = "Select * From sjk Where [User]='" & TextBox1.Text & "' AND [Password]='" & TextBox2.Text & "'"
Dim CmdTemp As New OleDb.OleDbCommand(StrSQL, ConnTemp)
ConnTemp.Open()'这里有问题运行到这里就不能执行下去了
Total = CmdTemp.ExecuteScalar
If Total > 0 Then
MessageBox.Show("密码或用户名错误!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If 展开
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Total As Integer
Dim StrConnApp = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & "setting.mdb"
Dim ConnTemp As New OleDb.OleDbConnection
Dim StrSQL As String
ConnTemp.ConnectionString = StrConnApp
StrSQL = "Select * From sjk Where [User]='" & TextBox1.Text & "' AND [Password]='" & TextBox2.Text & "'"
Dim CmdTemp As New OleDb.OleDbCommand(StrSQL, ConnTemp)
ConnTemp.Open()'这里有问题运行到这里就不能执行下去了
Total = CmdTemp.ExecuteScalar
If Total > 0 Then
MessageBox.Show("密码或用户名错误!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If 展开
2个回答
展开全部
检查数据库连接字符串是否正确,再查SQL语句是否正确
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询