Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    aspx registration form help

    Hey guys, so im really knew to aspx. I'm trying to create a registration form that connects to my access database and once a user registers it sends their information to the database.
    But when i run my code it goes straight to catch as exception.
    Here is my code,the code i have colored in red below may be causing the problem as i do not know exactly how to code it.
    Suggestions would be appritiated.



    <script runat="server">
    Dim conn As New OleDbConnection("provider=microsoft.Jet.OLEDB.4.0;" & _
    "Data source=" & AppDomain.CurrentDomain.BaseDirectory & "App_Data\webproject1.mdb")
    Dim sqlcomand As New OleDbCommand

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

    sqlcomand.Connection = conn
    sqlcomand.Connection.Open()
    Try
    sqlcomand.CommandText = "insert into Registration " & _
    "(FirstName,LastName,Age,Gender,Address,PostCode,Email,Username,Password) Values " & "('" & _
    txtfirstname.Text & "'," & _
    txtlastname.Text & "," & _
    txtage.Text & ",'" & _
    txtgender.Text & "'," & _
    txtadress.Text & "," & _
    txtemail.Text & ",'" & _
    txtusername.Text & ",'" & _
    txtpassword.Text & "')"
    sqlcomand.ExecuteNonQuery()
    MsgBox("thanks for registering please login")


    Catch ex As Exception
    MsgBox("Error you cannot register")
    End Try
    End Sub

  • #2
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post
    The problem is with your msgbox() command.
    The msgbox is trying to display on server.
    It cannot hence error.
    You need to use a clientscript (javascript) and use it with asp.net to display alert(). There are many articles on Internet on this.
    Search "Page.ClientScript"

  • #3
    New to the CF scene
    Join Date
    Oct 2010
    Location
    Slovenia
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Most simple way is to use:

    Response.Write("<script type=\"text/javascript\"> alert('thanks for registering please login');</script>");

  • #4
    Regular Coder
    Join Date
    Apr 2003
    Location
    Northern California
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Alternatively you could do something like this.

    Code:
                Dim scriptBlock As String = "<script type=""text/javascript"">"
                scriptBlock += "alert('thanks for registering please login');"
                scriptBlock += "</script>"
                ClientScript.RegisterClientScriptBlock(Page.GetType(), "scriptKey", scriptBlock)
    With this method you can access and modify the script block server side using the provided key "scriptKey".

    Hope it helps.
    -When you do things right, people won't be sure you've done anything at all


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •