Monday, March 26, 2012

multi line rows

Using Visual basic 2005

I have a form and set up my datasource, bindings etc.

All works well, adding, updating, and deleting via form to sqlexpress except.....

I have 2 columns set up in sqlserver that get data from muliline textboxes on my form.

Column 1 "Material" is nvarchar(50)

Column 2 "Quantity" is int

The first multine textbox "Material" works fine, eather updating in the textbox or in the Datagridview cell.

the second multiline textbox "Quantity" works when I just put in a number in the first line of the multiline textbox, when I put in the 2nd number on the second line, nothing gets updated.

I I do that in the datagridview cell (Shift-Enter), I get an error.

"System string was not in correct format".

I tried integer.parse, but that dosn't work. I'm assuming it has something to do with the next line ascii code or something like that.

Can anyone out there help with this

It sounds like the problem is that you are trying to treat a multi-line textbox as a collection of values for when updating to the database... instead of the single long string value.

When saving your results back to the database instead of dealing with the textbox’s Text property, try iterating through each of the lines within its Lines property to pull out each individual value, convert it to a number and then deal with it as needed.

|||

Hi nglow,

Did Brendan's answer resolve your issue? I believe he's correct that the integer field is not going to accept all the lines from your multi-line text box as this is returning a string. The integer field can only hold a single integer number and you seem to be suggesting that you want to put more than one number in it. That won't work.

You either need to limit the text box to a single number, or walk each line in the text box and put each number into a separate row in the database.

Regards,

Mike Wachal
SQL Express team

Mark the best post as Answered.

No comments:

Post a Comment