Why doesn't this INSERT work please?

  • Thread starter Thread starter Trint Smith
  • Start date Start date
T

Trint Smith

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
(e-mail address removed)
 
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]
 
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
(e-mail address removed)
 
Back
Top