|
-
Mar 20th, 2006, 04:23 PM
#1
Thread Starter
New Member
Oledb Insert into access Db
I have a web form coded as follows
<form id="form1" method="post" action="default.aspx" runat="server">
Location: <input id="txt_location" type="text" name="txt_location" /><br />
Name: <input id="txt_name" type="text" name="txt_name" /><br />
E-Mail: <input id="txt_email" type="text" name="txt_email" /><br />
Telephone Number: <input id="txt_telno" type="text" name="txt_telno" /><br />
<input id="Submit1" type="submit" value="submit" runat="server" />
<asp:Label ID="label1" runat="server" Text="Label"></asp:Label>
</form>
Basically this is just four input text fields I want to pull info from and enter into an access db. The code I have on the button is as follows.
Imports System.Data
Imports System.Data.OleDb
Partial Class contact_us_default
Inherits System.Web.UI.Page
Protected Sub Submit1_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit1.ServerClick
Dim cn
Dim str
Dim cmd
Dim txt_location = Request.Form("txt_location")
Dim txt_name = Request.Form("txt_name")
Dim txt_email = Request.Form("txt_email")
Dim txt_telno = Request.Form("txt_telno")
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\_database\contact.mdb;")
cn.Open()
str = "insert into t_contact values('" & txt_location & "','" & txt_name & "','" & txt_email & "','" & txt_telno & "')"
cmd = New OleDbCommand(str, cn)
Catch
End Try
cn.Close()
Label1.Text = "Database now updated"
End Sub
End Class
When I click the button label1.text chnges to "Database now updated" so the sub definately runs but no information is entered in to the database and I do not get any errors.
Any help would be greatly appreciated.
Thank You.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|