Dim nm As String
Dim pass As String
nm = TextBox1.Text
pass = TextBox2.Text
Try
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Pavilion\Documents\Visual Studio 2010\Projects\WindowsApplication5\Ent.accdb"
cn.Open()
Dim sql As String
sql = "SELECT * FROM user WHERE UName='" & nm & "'AND Pwd='" & pass & "'"
cmd = New OleDbCommand(sql, cn)
dr = cmd.ExecuteReader
While (dr.Read())
If ((nm.Equals(dr(0))) And pass.Equals(dr(1))) Then
MessageBox.Show("Login Sucessful")
End If
End While
Catch ex As Exception
MsgBox("Login Failed :" & ex.Message)
End Try
此代碼是給下面的錯誤syntax error in FROM clause
語法錯誤在vb.net
仍然無法工作 – Priyanshu
這段代碼與OP的發佈代碼有什麼不同?除了移動try塊的開始,我看不到任何區別...... – Tim
你的編輯**仍然**不回答這個問題 - 它是OP在問題中張貼的**完全相同的代碼** !如果你要回答一個問題,然後回答它 - 並在代碼中發佈解釋*幾乎總是有幫助的。 – Tim