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 6 944
Where are you opening and closing the database connection?
"Sparky Arbuckle" <tw*@secureroot.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... 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
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
Any suggestions as to why this isn't working?
Sparky..
Whats the exact error u are getting?
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I'm not getting an error. It's just not writing. I ended up fixing it
with;
ObjCmd.ExecuteNonQuery
Good Sparky..
I didn't expect u weren't adding :-
ObjCmd.ExecuteNonQuery :(
Anyway good u saw what was wrong..
Happy .Netting!!!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Randell D. |
last post by:
Folks,
I've heard of buffer overflows being used/abused by hackers and believe one
method to reduce this from happening is to check the length of my form data
before writing it to my MySQL...
|
by: sedefo |
last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i
was researching how i can write a database independent data access layer. In
my company we already use Data Access...
|
by: cryptic_blade |
last post by:
I am working on the design for a new application and want to make the
program fully object oriented. I have built and used C++ classes
before, but never with a database driven application. Should...
|
by: adrin |
last post by:
hi,
i am writing a program that is supposed to create a database of my music
and albums.
i want it to consist of 3 'modules' input<->processing<->output. input
should enable reading data from cd...
|
by: laimis |
last post by:
Hey guys,
I just recently got introduced to data mappers (DTO mapper). So now I
have a SqlHelper being used by DTOMapper and then business layer is
using DTOMapper when it needs to persist...
|
by: Chris Springer |
last post by:
I'd like to get some feedback on the issue of storing data out to disk and
where to store it. I've never been in a production environment in
programming so you'll have to bear with me...
My...
|
by: asad |
last post by:
hello, how ru all
pls tell me how can i create DAL and how can i use it in my ASP.NET pages
thanks
|
by: Sjaakie |
last post by:
Hi,
I'm, what it turns out to be, fooling around with 3-tier design.
At several websites people get really enthusiastic about using custom
dataobjects instead of datasets/-tables.
While trying to...
|
by: AAJ |
last post by:
Hi all
FIRST THE BORING BITS.......
I normally use a Database layer, a Business layer and a GUI layer.
The GUI uses an Object data source to bind to the Business layer which in
turn binds...
|
by: rustyc |
last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-)
As I said over there:
... for a little side project at home, I'm writing a ham radio web site in...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |