注册 登录
编程论坛 ASP.NET技术论坛

做的一个简单的登陆页面用的access数据源各位高手帮我看看啊~

damelly 发布于 2008-01-11 23:52, 995 次点击
Dim connstr As String

        connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("./") & "App_Data/book.mdb"

        Dim myConn As New Data.OleDb.OleDbConnection(connstr)
        Dim ole As String
        ole = "SELECT * FROM [UserInfo]where UserID='" + TextBox1.Text + "' or UserPassWord='" + TextBox2.Text + "' "
        Dim mycmd As New Data.OleDb.OleDbCommand(ole, myConn)
        myConn.Open()


        Dim read As Data.OleDb.OleDbDataReader = mycmd.ExecuteReader()
        If (read.Read()) Then
            If read.GetValue(0).ToString = TextBox1.Text Then
                If read.GetValue(1).ToString = TextBox2.Text Then
                    Response.Redirect("Default2.aspx")
                End If
                Response.Write("密码错误")
            End If
            Response.Write("用户名错误")





        End If


它老说 read As Data.OleDb.OleDbDataReader = mycmd.ExecuteReader()标准表达式中数据类型不匹配
2 回复
#2
lxd8242008-01-12 19:35
"SELECT * FROM [UserInfo]where UserID='" + TextBox1.Text + "' or UserPassWord='" + TextBox2.Text + "' "有问题

"SELECT * FROM  [UserInfo] where UserID='" + TextBox1.Text + "' and UserPassWord='" + TextBox2.Text + "' "
在where前面加个空格还有应该是用and不是用or吧!
1