from子句的语法错误 [英] syntax error from clause

查看:87
本文介绍了from子句的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

带星号的行是错误所在的行,但我不知道是什么导致该行错误!任何的想法????请帮助呵呵


The line with the asterisk is the line where the error is but I don''t know what make that line error! Any idea???? please help hehhe


Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

     Dim intResult As Integer
     conn = New OleDbConnection(strConn)
     conn.Open()

     ' Catch sa error k2ng form clause
     Try
         strSQL = "SELECT * FROM User WHERE (Username LIKE ?) AND (Password LIKE ?)"the

         'strSQL = "SELECT * FROM User WHERE Username = @Username AND Password = @Password"

         Dim dbCmd As New OleDbCommand(strSQL, conn)
         'G Add lng
         'dbCmd.CommandType = CommandType.Text

         dbCmd.Parameters.AddWithValue("Username", txtUsername.Text)
         dbCmd.Parameters.AddWithValue("Password", txtPassword.Text)
        ****** dbReader = dbCmd.ExecuteReader()


         Using dbReader
             If dbReader.Read() Then
                 Dim strResult1 As String = dbReader.Item("Username")
                 Dim strResult2 As String = dbReader.Item("Password")

                 If chkRememberUsername.Checked = True Then
                     My.Settings.Username = txtUsername.Text
                     My.Settings.Save()
                     My.Settings.Reload()

                 End If

                 Me.Close()
                 mediaSoundPlayer.Stream = My.Resources.tada
                 mediaSoundPlayer.Play()

                 frmLoading.ShowDialog()

                 'frmMain.LogOffToolStripMenuItem.Text = "Log Off"
                 'frmMain.SettingToolStripMenuItem.Enabled = True
                 frmMain.LogOffToolStripMenuItem.Text = "Log Off"
                 Me.Close()
                 frmMain.Show()
             Else

                 intResult = MessageBox.Show("Invalid Username Or Password", "Login", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)


                 If intResult = DialogResult.Cancel Then
                     Me.Close()

                 Else
                     intResult = DialogResult.Retry
                     Me.Show()

                 End If
                 frmMain.SettingsToolStripMenuItem.Enabled = False
                 frmMain.LogOffToolStripMenuItem.Text = "Login"


             End If


         End Using
         conn.Close()


     Catch ex As Exception
         MsgBox("System Error", MsgBoxStyle.Critical, "Error in login")
     End Try
     'frmMain.Show()



 End Sub

推荐答案

现在它说dbdatareader未定义……对此有任何想法?
now it says dbdatareader is not define...... any idea about this??


好像您尚未声明读取器.

在方法顶部插入以下内容

Looks like you have not declared the reader.

Insert the following at the top of the method

Dim dbReader as DbDataReader  OleDbDataReader= Nothing



我更改了对象类型,只是在使用OleDbCommand通知您时,该对象从ExecuteReader函数返回了不同的类型.



I have changed the Object Type, as only just noticied you where using OleDbCommand which returns a different type from the ExecuteReader function.


这篇关于from子句的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆