未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。 10
我弄了个登陆程序Importssystem.dataImportsSystem.Data.SqlClientPublicClassForm2Dimf3AsNewForm3...
我弄了个登陆程序Imports system.data
Imports System.Data.SqlClient
Public Class Form2
Dim f3 As New Form3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myconn As New SqlConnection("Data Source=2BE1F319C37A4CB;Initial Catalog=教材管理系统;Integrated Security=True")
myconn.Open()
Dim mysql As String
mysql = "slsct * from 用户 where username='" & Me.TextBox1.Text & "'and passwd='" & Me.TextBox2.Text & "'"
Dim myadapter As New SqlDataAdapter(mysql, myconn)
Dim mydb As New DataSet
mydb.Clear()
myadapter.Fill(mydb, "user")
If mydb.Tables("user").Rows.Count = 0 Then
MsgBox("用户名或密码错误!")
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Else
If (mydb.Tables("user").Rows(0).Item(2) = 0) Then
f3.系统管理.Visible = True
End If
If (mydb.Tables("user").Rows(0).Item(2) = 1) Then
f3.系统管理.Visible = False
f3.ToolStripMenuItem6.Visible = False
End If
If (mydb.Tables("user").Rows(0).Item(2) = 2) Then
f3.系统管理.Visible = False
End If
Me.Hide()
f3.Show()
End If
End Sub
End Class
可执行到myadapter.Fill(mydb, "user")就会出现
未处理 System.Data.SqlClient.SqlException
Class=15
ErrorCode=-2146232060
LineNumber=1
Message="第 1 行: '*' 附近有语法错误。"
Number=170
是怎么回事啊!请大虾指点啦! 展开
Imports System.Data.SqlClient
Public Class Form2
Dim f3 As New Form3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myconn As New SqlConnection("Data Source=2BE1F319C37A4CB;Initial Catalog=教材管理系统;Integrated Security=True")
myconn.Open()
Dim mysql As String
mysql = "slsct * from 用户 where username='" & Me.TextBox1.Text & "'and passwd='" & Me.TextBox2.Text & "'"
Dim myadapter As New SqlDataAdapter(mysql, myconn)
Dim mydb As New DataSet
mydb.Clear()
myadapter.Fill(mydb, "user")
If mydb.Tables("user").Rows.Count = 0 Then
MsgBox("用户名或密码错误!")
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Else
If (mydb.Tables("user").Rows(0).Item(2) = 0) Then
f3.系统管理.Visible = True
End If
If (mydb.Tables("user").Rows(0).Item(2) = 1) Then
f3.系统管理.Visible = False
f3.ToolStripMenuItem6.Visible = False
End If
If (mydb.Tables("user").Rows(0).Item(2) = 2) Then
f3.系统管理.Visible = False
End If
Me.Hide()
f3.Show()
End If
End Sub
End Class
可执行到myadapter.Fill(mydb, "user")就会出现
未处理 System.Data.SqlClient.SqlException
Class=15
ErrorCode=-2146232060
LineNumber=1
Message="第 1 行: '*' 附近有语法错误。"
Number=170
是怎么回事啊!请大虾指点啦! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询