一个比较郁闷的问题!!
代码如下:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" theme="Theme1" Debug="true"%>
<%@ Import Namespace="System.Data"%>
<%@ Import NameSpace="System.Data.OleDb"%>
<script runat="server">
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim myconnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" & Server.MapPath("db.mdb"))
        Try
            myconnection.open()
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
        
        Select Case Me.DropDownList1.SelectedValue
            Case "注册"
                Try
                    Dim sql = "Insert INTO userinfo (username,password) Values ('" & Me.username.Text & "','" & Me.password.Text & "')"
                    Dim mycommand = New OleDbCommand(Sql, myconnection)
                    mycommand.ExecuteNonQuery()
                    Me.Label3.Text = "注册成功,请登陆!"
                    Me.username.Text = ""
                    Me.password.Text = ""
                Catch ex As Exception
                    Response.Write(ex.Message)
                    Me.username.Text = ""
                    Me.password.Text = ""
                    Me.Label3.Text = ""
                End Try
            Case "登陆"
                Try
                    Dim Sql = "select * from userinfo where username='" + Me.username.Text + "' and password='" + Me.password.Text + "'"
                    Dim mycommand = New OleDbCommand(Sql, myconnection)
                    Dim mydatereader As OleDbDataReader
                    mydatereader = mycommand.executereader()
                    If Not mydatereader.Read() Then
                        Me.Label3.Text = "登陆失败!"
                        Me.username.Text = ""
                        Me.password.Text = ""
                    Else
                        Me.Label3.Text = "登陆成功!"
                        Me.username.Text = ""
                        Me.password.Text = ""
                    End If
                Catch ex As Exception
                    Response.Write(ex.Message)
                    Me.username.Text = ""
                    Me.password.Text = ""
                    Me.Label3.Text = ""
                End Try
        End Select
    End Sub
</script><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="Label1" runat="server" Text="用户名"></asp:Label>
    <asp:TextBox ID="username" runat="server"></asp:TextBox><br />
    <asp:Label ID="Label2" runat="server" Text="密 码"></asp:Label>
    <asp:TextBox ID="password" runat="server" TextMode="Password"></asp:TextBox>&nbsp;<br />
    <asp:DropDownList ID="DropDownList1" runat="server">
        <asp:ListItem>注册</asp:ListItem>
        <asp:ListItem>登陆</asp:ListItem>
    </asp:DropDownList>
    <asp:Button ID="Button1" runat="server" Text="确定" OnClick="Button1_Click" />
    <asp:Label ID="Label3" runat="server" Text="" Width="106px"></asp:Label><br />
</asp:Content>代码其实很简单,不知道为什么点击"注册"的总是提示:INSERT INTO 语句的语法错误。 这样的信息!