473,658 Members | 2,623 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.Connection String = "Password=angie p;Persist Security
Info=True;User ID=trint;Initia l 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_numb er, buyr_fname, buyr_lname, buyr_cphone,
buyr_baddress1, " & _
"buyr_baddress2 , buyr_bcity, buyr_bstate, buyr_bzip,
buyr_bstateprov ," & _
"buyr_bcoun try, buyr_buserid, buyr_bpassword,
buyr_bemail, buyr_bavatar," & _
"buyr_bsaddress 1, buyr_bsaddress2 , buyr_bscity,
buyr_bsstate, buyr_bszip," & _
"buyr_bsstatepr ov, 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.ExecuteNonQ uery()
Catch ex As SqlException
Console.WriteLi ne("An exception of type " &
ex.GetType().To String() & _
" 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********@hotm ail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
2 878
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********@hot mail.com> wrote in message
news:es******** ******@TK2MSFTN GP10.phx.gbl...
Dim conn As New SqlConnection
conn.Connection String = "Password=angie p;Persist Security
Info=True;User ID=trint;Initia l 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_numb er, buyr_fname, buyr_lname, buyr_cphone,
buyr_baddress1, " & _
"buyr_baddress2 , buyr_bcity, buyr_bstate, buyr_bzip,
buyr_bstateprov ," & _
"buyr_bcoun try, buyr_buserid, buyr_bpassword,
buyr_bemail, buyr_bavatar," & _
"buyr_bsaddress 1, buyr_bsaddress2 , buyr_bscity,
buyr_bsstate, buyr_bszip," & _
"buyr_bsstatepr ov, 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.ExecuteNonQ uery()
Catch ex As SqlException
Console.WriteLi ne("An exception of type " &
ex.GetType().To String() & _
" 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********@hotm ail.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********@hotm ail.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
7379
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 atmosphere. Good food.", " (Harry Houdini - 03/01/2004)"); INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada", " (Herbert Hoover - 03/03/2004)"); INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
16
17004
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 must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
3
11071
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 tmp="12345678901234567890"; string toinsert="HELLO"; tmp.Insert(10,toinsert); MessageBox.Show(tmp);
1
1670
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. But when I press the "insert" link, it never seems to go to the DataGrid1_ItemCommand routine. ************************************************************************************** <%@ Page Language="vb" trace="true" debug="true" %> <%@ Import...
1
7652
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 than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement this is my insert : Dim queryString2 = "INSERT INTO
1
1081
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 trigger that calls this function runs after for insert, update and delete.
4
3690
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 that starting on 4/25/2006 the dump files are empty and only shows a few lines of comments or something instead of creating a normal dump as it had been doing just fine for the last few weeks. Quote:
0
1255
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 that one Select statement doesn't execute, does anyone have a clue for this? IF @CourseList <> '' AND @EmployeeID <> 'DELETE' BEGIN SELECT @npos1Course = 1 SELECT @npos1RBY = 1 SELECT @nLoop = 1 SELECT @nBreak = 0 ...
3
5540
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 method=\"post\" action=\"".$_SERVER."\"> <p><strong>First/Last Names:</strong><br/> <input type=\"text\" name=\"f_name\" size=\"30\" maxlength=\"75\">
39
5849
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 ISO-8859-1 -t UTF-8 mydb.sql mydb_utf8.sql mysqlCREATE DATABASE mydb_utf8 CHARACTER SET utf8 COLLATE utf8_general_ci;
0
8427
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.