C
cameron.waldron
I'm trying to insert data into a csv file using System.Data.OleDb but
I'm unable to insert rows with character fields bigger that 255
characters.
the code:
const String INSERT_STATEMENT = "insert into [table#csv] (SmallStr,
BigStr) values (@SmallStr, @BigStr)";
OleDbConnection oConn = new
OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=c:\\db\
\;Extended Properties=\"text;HDR=YES;\"");
oConn.Open();
OleDbCommand oCmd = new OleDbCommand(INSERT_STATEMENT,
oConn);
OleDbParameter oParam = null;
oParam = new OleDbParameter("SmallStr", OleDbType.VarChar,
255);
oParam.Value = "0123456789";
oCmd.Parameters.Add(oParam);
oParam = new OleDbParameter("BigStr",
OleDbType.LongVarChar, 1024);
oParam.Value =
"012345678901234567890123456789012345678901234567890123456789012345"+
"678901234567890123456789012345678901234567890123456789012345678901234567890123"+
"456789012345678901234567890123456789012345678901234567890123456789012345678901"+
"23456789012345678901234567890123456789"; //260
characters
oCmd.Parameters.Add(oParam);
oCmd.ExecuteNonQuery();
The above does work if i change the BigStr param to 255 chars or less.
I've tried playing around with putting status.ini files into the
folder in various configurations but nothing seems to help.
I'm hoping though that it is possible to get more than 255 characters
into a text file using OleDb and Jet.
If anyone could help me with this I would be very greatful, spent ages
trying to get it right.
Thanks in advance
I'm unable to insert rows with character fields bigger that 255
characters.
the code:
const String INSERT_STATEMENT = "insert into [table#csv] (SmallStr,
BigStr) values (@SmallStr, @BigStr)";
OleDbConnection oConn = new
OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=c:\\db\
\;Extended Properties=\"text;HDR=YES;\"");
oConn.Open();
OleDbCommand oCmd = new OleDbCommand(INSERT_STATEMENT,
oConn);
OleDbParameter oParam = null;
oParam = new OleDbParameter("SmallStr", OleDbType.VarChar,
255);
oParam.Value = "0123456789";
oCmd.Parameters.Add(oParam);
oParam = new OleDbParameter("BigStr",
OleDbType.LongVarChar, 1024);
oParam.Value =
"012345678901234567890123456789012345678901234567890123456789012345"+
"678901234567890123456789012345678901234567890123456789012345678901234567890123"+
"456789012345678901234567890123456789012345678901234567890123456789012345678901"+
"23456789012345678901234567890123456789"; //260
characters
oCmd.Parameters.Add(oParam);
oCmd.ExecuteNonQuery();
The above does work if i change the BigStr param to 255 chars or less.
I've tried playing around with putting status.ini files into the
folder in various configurations but nothing seems to help.
I'm hoping though that it is possible to get more than 255 characters
into a text file using OleDb and Jet.
If anyone could help me with this I would be very greatful, spent ages
trying to get it right.
Thanks in advance