Is there a way to allow data to get truncated if its too long when inserting it from one
row to another row? Whats happening now is that it gets an error and doesn’t add the row if one of the fields is too long.
Here is the piece of code that I have:
DataRow dr = dt.NewRow();
for (int j = 0; j < edi50.Columns.Count; j++)
dr[j] = dr50[j];
dt.Rows.Add(dr);
try
{
RemoveNulls(dt);
daEDI40050.Update(dt);
}
catch (Exception e)
{
string m = e.Message;
}
I have a description field 25 chars long but the data is 34 chars going into it. I want to be able to have it insert the 25 and truncate the rest and still add the row.
thank you
You could get the schema from database first(untested):
and then something similar to this:
Again, totally untested and written from scratch, but it might give you an idea how to get the column size. Of course this works only for
string, but i assume that this is what you want.