Form子句Vb.net中的语法错误

时间:2015-05-31 23:42:29

标签: asp.net database vb.net

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
Form子句中的

语法错误我试图保存数据库变量,以便我可以使用它们与文本框进行比较 我的数据库名是database.accdb 表名:user-table 字段:用户名,密码,类型

0 个答案:

没有答案