473,505 Members | 13,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why doesn't this INSERT work please?

Dim conn As New SqlConnection
conn.ConnectionString = "Password=angiep;Persist Security
Info=True;User ID=trint;Initial Catalog=tribidz;Data Source=TRINITY"
Dim cmd As New SqlCommand
With cmd
.Connection = conn
End With
Try
conn.Open()
cNumber = "999999999"
cmd.CommandText = "INSERT TBL_RegBuyer" & _
"(buyr_number, buyr_fname, buyr_lname, buyr_cphone,
buyr_baddress1," & _
"buyr_baddress2, buyr_bcity, buyr_bstate, buyr_bzip,
buyr_bstateprov," & _
"buyr_bcountry, buyr_buserid, buyr_bpassword,
buyr_bemail, buyr_bavatar," & _
"buyr_bsaddress1, buyr_bsaddress2, buyr_bscity,
buyr_bsstate, buyr_bszip," & _
"buyr_bsstateprov, buyr_bscountry, buyr_bccname,
buyr_bccnumber," & _
"buyr_bccxmonth, buyr_bccxyear)" & _
" VALUES('" & cNumber & "'," & _
"'" & fName & "'," & _
"'" & lName & "'," & _
"'" & cPhone & "'," & _
"'" & Address1 & "'," & _
"'" & Address2 & "'," & _
"'" & City & "'," & _
"'" & State & "'," & _
"'" & Zip & "'," & _
"'" & StateProv & "'," & _
"'" & Country & "'," & _
"'" & UserID & "'," & _
"'" & PasswordA & "'," & _
"'" & Email & "'," & _
"'" & Avatar & "')"
cmd.ExecuteNonQuery()
Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter personal
data.")
'*********
Finally
conn.Close()
End Try

There is no error message from the 'catch ex'
I don't see a problem with the sql srvr 2k data base or the table I
created either????
Thanks,
Trint
.Net programmer
tr********@hotmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
2 873
Didn't see anything glaringly wrong off the bat, but try adding a "Catch Ex
As Exception" clause to your try block to see if you are getting something
other than a sql exception. It's possible you have a null reference or
something similar in there somewhere.

-Rob Teixeira [MVP]

"Trint Smith" <tr********@hotmail.com> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
Dim conn As New SqlConnection
conn.ConnectionString = "Password=angiep;Persist Security
Info=True;User ID=trint;Initial Catalog=tribidz;Data Source=TRINITY"
Dim cmd As New SqlCommand
With cmd
.Connection = conn
End With
Try
conn.Open()
cNumber = "999999999"
cmd.CommandText = "INSERT TBL_RegBuyer" & _
"(buyr_number, buyr_fname, buyr_lname, buyr_cphone,
buyr_baddress1," & _
"buyr_baddress2, buyr_bcity, buyr_bstate, buyr_bzip,
buyr_bstateprov," & _
"buyr_bcountry, buyr_buserid, buyr_bpassword,
buyr_bemail, buyr_bavatar," & _
"buyr_bsaddress1, buyr_bsaddress2, buyr_bscity,
buyr_bsstate, buyr_bszip," & _
"buyr_bsstateprov, buyr_bscountry, buyr_bccname,
buyr_bccnumber," & _
"buyr_bccxmonth, buyr_bccxyear)" & _
" VALUES('" & cNumber & "'," & _
"'" & fName & "'," & _
"'" & lName & "'," & _
"'" & cPhone & "'," & _
"'" & Address1 & "'," & _
"'" & Address2 & "'," & _
"'" & City & "'," & _
"'" & State & "'," & _
"'" & Zip & "'," & _
"'" & StateProv & "'," & _
"'" & Country & "'," & _
"'" & UserID & "'," & _
"'" & PasswordA & "'," & _
"'" & Email & "'," & _
"'" & Avatar & "')"
cmd.ExecuteNonQuery()
Catch ex As SqlException
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to enter personal
data.")
'*********
Finally
conn.Close()
End Try

There is no error message from the 'catch ex'
I don't see a problem with the sql srvr 2k data base or the table I
created either????
Thanks,
Trint
Net programmer
tr********@hotmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #2
Thanks,
It was the fields were more than the values...fixed that...then it was
the size of the fields were smaller than two of the values and now it
seems to work.
Trint

.Net programmer
tr********@hotmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
7363
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
16
16975
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
3
11060
by: Steph. | last post by:
Hi, String.Insert doesn't seems to work.... (see example below) Could someone explain me this ? : private void button1_Click(object sender, System.EventArgs e) { string...
1
1664
by: tshad | last post by:
I can't seem to get insert into a DataGrid to work. I am using an example from the net and made changes to work on my computer. The grid comes up fine. The edit boxes in the footer are there. ...
1
7644
by: ven | last post by:
hello i`m makin a asp.net service with database connection where i have an insert with decimal value, when i run my function i get this error : There are fewer columns in the INSERT statement...
1
1071
by: Graeme Hinchliffe | last post by:
Hiya, I am using the following line to retrieve the attribute name of the 1st column for a table on which a trigger has been fired. idfield=SPI_fname(trigdata->tg_relation->rd_att,0); The...
4
3681
by: Robert Blackwell | last post by:
A while ago I had some help from here to make a batch file that would dump my db. Everything was working just fine until 2 days ago and I just found out. I checked my backup folder and found...
0
1243
by: zhengmao | last post by:
I have one store procedure, which works fine in SQL Analyzer when I test it out, but doesn't work when I call it in web application. the problem is it doesn't insert last line, and the problem is...
3
5534
by: whitey | last post by:
this code is producing the message BUT it is entering the data. What should i do? <?php if (!$_POST) { //haven't seen the form, so show it $display_block = " <form...
39
5823
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.