if Not IsPostBack Then
conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("xxx/xxx.mdb"))
conn.open()
cmd=new OleDbcommand("select *from 用户管理 where 用户名='"&name.text&"'",conn)
rs=new OleDbdatareader
rs=cmd.executereader()
if rs.read() then
msgbox("此用户名已经存在!")
name.text=""
name.focus
else
end if
运行后出现以下错误:
Compiler Error Message: BC30455: Argument not specified for parameter 'connection' of 'Public Sub New(cmdText As String, connection As System.Data.OleDb.OleDbConnection, transaction As System.Data.OleDb.OleDbTransaction)'.

解决方案 »

  1.   

    改成下面的试试:
    if Not IsPostBack Then
    Dim conn As New OleDbConnection()
    conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("xxx/xxx.mdb"))
    conn.open()
    Dim cmd As New OleDbcommand()
    cmd=new OleDbcommand("select *from 用户管理 where 用户名='"&name.text&"'",conn)
    Dim rs As New OleDbdatareader()
    rs=cmd.executereader()
    if rs.read() then
    msgbox("此用户名已经存在!")
    name.text=""
    name.focus
    else
    end if
      

  2.   

    不好意思由于vb.net不熟。一楼上写的代码有问题。
      

  3.   

    "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("xxx/xxx.mdb")
    把上面的路径输出看看是否正确。
      

  4.   

    cmd=new OleDbcommand("select *from 用户管理 where 用户名='"&name.text&"'",conn)这句一直有问题!
    运行后出现以下错误:
    Compiler Error Message: BC30455: Argument not specified for parameter 'connection' of 'Public Sub New(cmdText As String, connection As System.Data.OleDb.OleDbConnection, transaction As System.Data.OleDb.OleDbTransaction)'.
      

  5.   

    这样试试:
    dim a as string
    a=name.text
    cmd=new OleDbcommand("select *from 用户管理 where 用户名='"&a&"'",conn)
      

  6.   

    if Not IsPostBack Then
    Dim conn As OleDbConnection
    conn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.mappath("xxx/xxx.mdb")
    conn.open()
    Dim cmd As OleDbcommand=new oledbcommand("select * from 用户管理 where 用户名='"&name.text&"'",conn)Dim rs As New OleDbdatareader()
    rs=cmd.executereader()
    if rs.read() then
    msgbox("此用户名已经存在!")
    name.text=""
    name.focus
    else
    end if
      

  7.   

    Dim conn As OleDbConnection
            Dim cmd As OleDbCommand
            Dim rs As OleDbDataReader
            If Not IsPostBack Then
                conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("grade.mdb"))
                conn.open()
                cmd = New OleDbCommand("select *from books where itemid='1'", conn)
                 rs = cmd.executereader()
                If rs.read() Then
                    'MsgBox("此用户名已经存在!")
                    'name.text = ""
                    'name.focus()
                Else
                End If
            End If
      

  8.   

    if Not IsPostBack Then
    conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("xxx/xxx.mdb"))
    conn.open()
    cmd=new OleDbcommand("select *from 用户管理 where 用户名='"&name.text&"'",conn)
    rs=new OleDbdatareader
    rs=cmd.executereader()
    if rs.read() then
    msgbox("此用户名已经存在!")
    name.text=""
    name.focus
    else
    end if
    改为:
    If Not IsPostBack Then
    Dim conn as new OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source="& Server.MapPath("xxx/xxx.mdb"))
    Dim comm as new OledbCommand("Select * From 用户管理 where 用户名='"& name.text.Trim.ToString() &"'",Conn)
    Try
    Conn.Open()
    Dim dr as OledbDataReader=comm.ExecuteReader()
    if dr.Read() Then
    msgbox("此用户名已经存在!")
    name.text=""
    Else
    'other code
    End If
    Catch ex as Exception
    Response.Write("错误信息:"  & ex.Message)
    Finally
    conn.Close()
    End Try
    End If
      

  9.   

    当然,你可以将我的定义去掉,如Dim conn ,Dim comm等...
      

  10.   

    现在可以运行了,但查不出数据库中与na.text相同的用户名信息if Not IsPostBack Then
    conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("data/data.mdb"))
    conn.open()
    cmd=new OleDbcommand("select * from 用户管理 where 用户名='"& na.text &"'",conn)
    rs=cmd.executereader()
    if rs.read() then
    msgbox("此用户名已经存在!")
    na.text="ok"
    na.focus
    else
    msgbox("增加成功!")
    end if
    conn.close
      

  11.   

    现在出现了这样一个问题
    就是当我点击FORM的的REG按钮时,应该执行
    if Not IsPostBack Then
    conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("data/data.mdb"))
    conn.open()
    cmd=new OleDbcommand("select * from 用户管理 where 用户名='"& na.text &"'",conn)
    rs=cmd.executereader()
    if rs.read() then
    msgbox("此用户名已经存在!")
    na.text="ok"
    na.focus
    else
    msgbox("增加成功!")
    end if
    conn.close
    代码,但是,我测试后发现程序确没有执行
    if Not IsPostBack Then
    end if
    之间的代码,这是怎么回事?
      

  12.   

    不知道你是怎么做的?一般来说,都是在页面端拖完控件后,比如拖一个Button控件。
    然后你双击这个控件,转入.aspx.vb的Button的Click事件下了.你将以上代码写到Button的Click事件下.能不执行吗?应给是不会的...如果还有问题,发消息给我.
      

  13.   

    我就是这么做的,
    我在 
    if Not IsPostBack Then
    end if
    之上写了一段程序就可以执行,但放在里面就不执行了还有,按钮调用CLICK函数的代码是不是这么写
    <asp:Button ID="regButton" runat="server" Text="注册" OnClick="regButton_Click"/>   
    其中regButton_Click就是函数名
      

  14.   

    这么说吧,我的页面里有若干个text和两个按钮,当我点击按钮1时,我希望在按钮1的click事件中根据text1里面的文字到数据库中查找是否有相同的。但我以上写的代码都查不到。还有在按钮1中是否必须加 not ispostback 吗?