Data Not Writing to Database

S

Sparky Arbuckle

I'm trying to add customers to the database with the following
Add_Customer sub routine. The problem is that it is not writing the
information to the database. Any suggestions as to how I can fix this
problem? I made sure to check the spelling of all the textboxes and
database fields. This is frustrating.

Sub Add(sender As Object, e As System.EventArgs)
'insert new data
Dim strText as string
Dim myConnection as String = "Provider=Microsoft.Jet.OLEDB.4.0;" &
_
"Data Source=DB.mdb"
Dim strSQL as string = "INSERT INTO tblCustomers " & _
"strEmail, strFName, strLName, strStreet, strCity, strState,
strZip VALUES " & _
"'" & tbEmail.text & "'," & _
"'" & tbFName.text & "'," & _
"'" & tbLName.text & "'," & _
"'" & tbStreet.text & "'," & _
"'" & tbCity.text & "'," & _
"'" & tbState.text & "'," & _
"'" & tbZip.text & "'"

ExecuteSQL(strSQL)
Response.redirect("default.aspx?add=success")

END Sub
 
S

Sparky Arbuckle

Sorry. It should look like this:

Sub Add(sender As Object, e As System.EventArgs)
'insert new data
Dim strText as string
Dim myConnection as String = "Provider=Microsoft.Jet.OLEDB.4.0;" &
_
"Data Source=DB.mdb"
Dim strSQL as string = "INSERT INTO tblCustomers " & _
"strEmail, strFName, strLName, strStreet, strCity, strState,
strZip VALUES " & _
"'" & tbEmail.text & "'," & _
"'" & tbFName.text & "'," & _
"'" & tbLName.text & "'," & _
"'" & tbStreet.text & "'," & _
"'" & tbCity.text & "'," & _
"'" & tbState.text & "'," & _
"'" & tbZip.text & "'"



Dim objConnection as New OLEDBConnection(myConnection)
Dim objCmd as New OLEDBCommand(strSQL, objConnection)
objCmd.Connection.Open()


ExecuteSQL(strSQL)
Response.redirect("default.aspx?add=success")


END Sub
 
S

Sparky Arbuckle

I'm not getting an error. It's just not writing. I ended up fixing it
with;

ObjCmd.ExecuteNonQuery
 
P

Patrick Olurotimi Ige

Good Sparky..
I didn't expect u weren't adding :-
ObjCmd.ExecuteNonQuery :(
Anyway good u saw what was wrong..
Happy .Netting!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top