odd behaviour adding record to sql database

  • Thread starter Thread starter Bryan
  • Start date Start date
B

Bryan

i have created a form to submit data to an sql database, and it seems to
work, except for one glitch. one of the fields, the "creditcardnumbertxt"
text box, when entering a number with more that 7 characters, does not work.
sql says it will be truncated. in the asp code, the database, and the sql
procedure, the field is correctly set to allow a (sql datablase) char type
of 18 characters in size.

here is the error it spits back
----------------------------------

String or binary data would be truncated.The statement has been
terminated..Net SqlClient Data Provider

-----------------------------------


in the code behind the page, these are the relevant lines:

------------------------------------
cmd.Parameters.Add(New SqlParameter("@credit_card_nbr", SqlDbType.Char, 18))

cmd.Parameters.Item("@credit_card_nbr").Value = RegCreditcardnumberTXT.Text

-----------------------------------


the relevant lines in the procedure in the sql server is

-----------------------------------


@credit_card_nbr char(18),

------------------------------------

any help would be great

thanks for the help

bryan
 
it is also 18

i checked these values a million times... im totally stumped.. thanks for
the help

bryan
 
Hi Bryan,

A couple of other ideas:
1. is the sequence of columns correct in the insert sp? Perhaps it is
trying to pass the param to the wrong col.
2. Messagebox.show regcredticardnumbertxt.text.length just to see what vb
..net thinks the textbox size is after key entry.

I remember running into this error myself, some time ago, and it wasn't the
col that was failing, it was something unrelated.

HTH,

Bernie
 
i have tried your suggestions... the order is correct in my procedure to
insert. also, the results for the length were correct, no added characters
or anything..

im just learning asp.net & vb.net and i must say.. this error has me totally
turned off it. i cant seem to figure it out. my experience learning java was
better.

if anyone has any otherideas.. please let me know.. i appreciate any
suggestion.

bryan
 
Hi Bryan,

I wish I had an idea that could help.

Can you send me the relevant code, info on the precise structure of the
table, etc? I could run it on my system to see if I have the same
experience.

Bernie
 
Hi Bryan,

Another idea - go into sql server enterprise manager and manually modify a
row - that col - with data in that col larger than 7 chars - does it work?

Bernie
 
i have found the problem.

i used a database design program to creat the schema for the database. for
some reason it changed the order of the columns. i didn't check for this, i
only looked for errors in the procedure and vb code orders.

thank you all for your help. i certainly hope my experience will aid someone
in the future.

regards.
bryan
 
Hi Bryan,

Glad you figured it out. Hang in there; the visual studio .net/sql server
world is the new frontier; it will overwhelm Java in short order, already
does, even though I admit it can use some tweaking.

Bernie
 
Back
Top