我的代码是连接到SQL数据库,输入用户密码,点登录,然后打开下一个界面,现在数据库是连上了,但IF语句无效,直接走ELSE,菜鸟一个,高手帮我改改~(这段代码原来连的是ACCESS数据源...
我的代码是连接到SQL数据库,输入用户密码,点登录,然后打开下一个界面,现在数据库是连上了,但IF语句无效,直接走ELSE,菜鸟一个,高手帮我改改~(这段代码原来连的是ACCESS数据源库) Dim sConnString As String = _ "Data Source =(local);Initial Catalog =LiMin SuperMarket Manage System;Integrated Security=SSPI" Dim myCn As New SqlConnection Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click Try myCn.ConnectionString = sConnString myCn.Open() Dim mySQL As String = "Select PersonnelID From Users Where Account='" & Me.boxname.Text & "' And Code='" & Me.PasswordTextBox.Text & "'" Dim sComm As New SqlCommand(mySQL, myCn) Dim s As Object = sComm.ExecuteScalar If sComm.ExecuteScalar Then Dim User_MainForm As New form1 User_MainForm.Show() Else MsgBox("用户名或密码不正确,请重试!") End If Catch ex As OleDbException MsgBox(ex.Message) Finally myCn.Close() '关闭连接 End Try End Sub
展开