Syntax error in Vb.net form clause

Dim provider As String
Dim dataFile As String
Dim connString As String
Public myConnection As OleDbConnection = New OleDbConnection
Public dr As OleDbDataReader
Public user As String
Public pass As String
Public type As String
Protected Sub Unnamed6_Click(sender As Object, e As EventArgs)


    Provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="
    dataFile = "H:\WebApplication2\WebApplication2\database.accdb"
    connString = provider & dataFile
    myConnection.ConnectionString = connString


    Try
        myConnection.Open()
        Dim g As String = Request.Form("txtusername2").ToString()
        Dim p As String = Request.Form("txtpassword2").ToString()
        Dim str As String
        str = "select * from user-table where username='" & g & "'"


        'pDT = databaseConnector.RunSqlQuery(fulltxtSQL)
        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
        dr = cmd.ExecuteReader
        While dr.Read()
            user = dr("username").ToString
            pass = dr("password").ToString
            type = dr("Type").ToString
        End While
        MsgBox(type)

        If pass = p Then
            Session("username") = g
            MsgBox(Session("username"))

            Response.Redirect("Default.aspx")

            MsgBox("thank you for loging in")
        End If
        myConnection.Close()

        Exit Sub

    Catch ex As Exception
        MsgBox(ex.Message.Trim, MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
    End Try

    Exit Sub

End Sub

      

Syntax error in Form am clause is trying to save database variables so I can use them to compare against a text field my database name is database.accdb table name: custom table fields: username, password, type

+3


source to share





All Articles