Cannot bind char column to textbox

  • Thread starter Thread starter Matt Fondoble
  • Start date Start date
M

Matt Fondoble

I have a form with multiple textboxes, checkboxes and comboboxes bound to a
dataset in VB 2003. I was forced to change the database structure of a
field from bigint to char. After changing the database and all associated
stored procedures, my textbox bound to the newly changed field will not
populate and I receive the error below.

Unhandled Exception: System.Data.SqlClient.SqlException: Error converting
data type varchar to bigint

I have narrowed down the problem to the line of code where is set the text
property of the textbox. If I comment out this line, every other control
populates normally. I've also tried putting the database value into the
text property of a label and displaying it in a message box. Those both
work as expected. I've also tried setting the value to a variable and then
assigning the variable to the textbox.text property to no avail.

Any ideas would be appreciated.

Matt Fondoble
 
Matt,

Is there any chance you have a mismatched middle tier to your database? Are
you sure you got all the sprocs changed?

One thing that would help in troubleshooting is if you could get a trace.
Go to the web.config and set TraceLevel to 4. Using the debug output
viewer and capture the trace output while reproing the problem and that will
spell out exactly what is going on.

Hope this helps,


Steve
 
I have a form with multiple textboxes, checkboxes and comboboxes bound to a
dataset in VB 2003. I was forced to change the database structure of a
field from bigint to char. After changing the database and all associated
stored procedures, my textbox bound to the newly changed field will not
populate and I receive the error below.

Unhandled Exception: System.Data.SqlClient.SqlException: Error converting
data type varchar to bigint

I have narrowed down the problem to the line of code where is set the text
property of the textbox. If I comment out this line, every other control
populates normally. I've also tried putting the database value into the
text property of a label and displaying it in a message box. Those both
work as expected. I've also tried setting the value to a variable and then
assigning the variable to the textbox.text property to no avail.

Any ideas would be appreciated.

Matt Fondoble

I have a similar app and had to get a little creative, may not be best
practices but it works well.

If you are just reading the data you should be able to add .ToString()
in the line that adds the db value to the text box like:

Me.txtTicketNumber.Text = reader("TicketNumberActual").ToString()
 
Matt,

I had the same yesterday, it was an orphaned binding.

Can you search your application with the fieldname that is used?

Cor
 
Guys,

Thanks for the help. It ended up that I had failed to change the DB type in
another table from bigint to char. I had changed all of the SP's which is
why I was getting the error.

Thanks again. Now......how do I put all of my hair back in.

Matt Fondoble
 
Back
Top