-
Connection string
Hi all i am using vb 2005 with an access database 2003 vb.net website (aspx page) i am try to put contact details in to the database with six text boves and one button (Button1) to submit the informaton in run time (aspx page) when i run the page no problems then i click submit no error but it does not send the information to the dadtbase.i put the code when i double click on the button here is my code could you plz tell what i am doing wrong thanks.
HTML Code:
Imports System.Data
Partial Class accessall_NewCustomer
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String
Dim cmd As OleDb.OleDbCommand
Dim con As New OleDb.OleDbConnection
Try
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\michael\Desktop\New Web Site\Motoglass0910new222.mdb"
con.Open()
str = "insert into CustomerAccountDetails values(" & CInt(SurNametxt.Text) & ",'" & ForeNametxt.Text & ",'" & Addresstxt.Text & ",'" & Towntxt.Text & ",'" & Postcodetxt.Text & "','" & _PhoneNotxt.Text & "')"
'string stores the command and CInt is used to convert number to string
cmd = New OleDb.OleDbCommand(str, con)
Catch
End Try
con.Close()
End Sub
End Class
-
Re: Connection string
"when i run the page no problems" -- I don't believe that... you could have an error and not even know it... what's the point of putting your code into a Try Catch if you're going to ignore any errors that happen?
What you have done is the .NET equivelent of On Error Resume Next.
That does nothing but ignore any errors that happen.
At the very least, throw up a message box.
Code:
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
-tg
-
Re: Connection string
thanks i am new to this i was trying to serch online sorry i don't know what i am doing but i wanted to give it a go on my on frist i will have an other go and get back to you