string not fully populated in sql

  • Thread starter Thread starter Michael de Vera
  • Start date Start date
M

Michael de Vera

To all,

I'm using the following to create a string of text and to insert into a
table/column:

strBuilder.append("User Full Name") ....this is inside a loop that may
increment 35 times. For 35 different names.

I then use the following code to insert the data into a table/column:

sqlCommand.Parameters.Add("@Full_NM", SqlDbType.VarChar, 2000)
sqlCommand.Parameters("@Full_NM").Direction = ParameterDirection.Input
sqlCommand.Parameters("@Full_NM").Size = Len(strBuilder.ToString)
sqlCommand.Parameters("@Full_NM").Value = strBuilder.ToString

However when I run my code not all the full names are entered into my table
and the number of characters are no more than 516 characters long .....so I'm
not going beyond 2000 characters. I also step through my code and see all
the values strBuilder.tostring to be correct. It's only different/truncated
after an insert occurs into my table. My table definition has the datatype
of varchar with a domain of 2000 characters. My data seems to get truncated
after 306 characters and after my code runs.

Any advise,
Michael
 
To all,

I'm using the following to create a string of text and to insert into a
table/column:

strBuilder.append("User Full Name") ....this is inside a loop that may
increment 35 times. For 35 different names.

I then use the following code to insert the data into a table/column:

sqlCommand.Parameters.Add("@Full_NM", SqlDbType.VarChar, 2000)
sqlCommand.Parameters("@Full_NM").Direction = ParameterDirection.Input
sqlCommand.Parameters("@Full_NM").Size = Len(strBuilder.ToString)
sqlCommand.Parameters("@Full_NM").Value = strBuilder.ToString

However when I run my code not all the full names are entered into my table
and the number of characters are no more than 516 characters long .....so I'm
not going beyond 2000 characters. I also step through my code and see all
the values strBuilder.tostring to be correct. It's only different/truncated
after an insert occurs into my table. My table definition has the datatype
of varchar with a domain of 2000 characters. My data seems to get truncated
after 306 characters and after my code runs.

Any advise,
Michael

Just an off the cuff thought, is it possible that after 306 characters
theres a null? Or even perhaps an apostrophe (')?

Chris
 
Chris,

Thanks for the response. After debugging my vb code and doing a sql
trace....I noticed that all characters in my parameter to be all there. The
thing that I did not do is set my column width in query analyzer to be more
than 256 charaters long.

Real fault on my part.

Thanks,
Michael
 
Back
Top