Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-23-2010, 04:59 AM   PM User | #1
slowbob!!
New to the CF scene

 
Join Date: Nov 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
slowbob!! is an unknown quantity at this point
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
slowbob!! is offline   Reply With Quote
Old 11-25-2010, 12:55 PM   PM User | #2
rpotech
New to the CF scene

 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
rpotech is an unknown quantity at this point
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"
rpotech is offline   Reply With Quote
Old 12-04-2010, 01:47 PM   PM User | #3
SresSi
New to the CF scene

 
Join Date: Oct 2010
Location: Slovenia
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
SresSi is an unknown quantity at this point
Most simple way is to use:

Response.Write("<script type=\"text/javascript\"> alert('thanks for registering please login');</script>");
SresSi is offline   Reply With Quote
Old 12-10-2010, 12:24 AM   PM User | #4
scriptkeeper
Regular Coder

 
Join Date: Apr 2003
Location: Northern California
Posts: 169
Thanks: 0
Thanked 0 Times in 0 Posts
scriptkeeper is an unknown quantity at this point
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
scriptkeeper is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:05 AM.


Advertisement
Log in to turn off these ads.