ASP.NET C# and OLEDB.JET problem

Joined
Oct 4, 2007
Messages
1
Reaction score
0
Hello!

I'm in trouble with the ASP.NET and OLEDB.JET connector.
When I put the data into an XLS file from a dataset of my webpage, everything's OK, but in the destination file there is an apostrophe in front of every numeric data.
It's problem for me, because there are some aritmethical operation with my datas in the XLS.
Here is my source code, what put the data into the file:

--------------------------------------------------------------------------------------

OleDbConnection connect = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(docpath)+"myfile.xls;Extended Properties=\"Excel 8.0;Readonly=False;IMEX=0;\"");
connect.Open();
...
PushToXls("A", objDataset1.Tables[0].Rows[3].ToString(), objDataset1.Tables[0].Rows[4].ToString(), objDataset1.Tables[0].Rows[5].ToString(), connect);
...
connect.Close();


private void PushToXls(string table, string first, string second, string third, OleDbConnection connect)
{

OleDbParameter pmfirst, pmsecond, pmthird;


if (first != "0")
{
pmfirst = new OleDbParameter("@first", OleDbType.Numeric);
pmfirst.Value = Convert.ToInt32(first);
}
else
{
pmfirst = new OleDbParameter("@first", OleDbType.VarChar);
pmfirst.Value = "";
}
if (second != "0")
{
pmsecond = new OleDbParameter("@second", OleDbType.Numeric);
pmsecond.Value = Convert.ToInt32(second);
}
else
{
pmsecond = new OleDbParameter("@second", OleDbType.VarChar);
pmsecond.Value = "";
}
if (third != "0")
{
pmthird = new OleDbParameter("@third", OleDbType.Numeric);
pmthird.Value = Convert.ToInt32(third);
}
else
{
pmthird = new OleDbParameter("@third", OleDbType.VarChar);
pmthird.Value = "";
}

string insertCommStr = "INSERT INTO " + table + "tart VALUES (@first, @second, @third)";
OleDbCommand insertcommand = new OleDbCommand(insertCommStr, connect);
insertcommand.Parameters.Add(pmfirst);
insertcommand.Parameters.Add(pmsecond);
insertcommand.Parameters.Add(pmthird);

insertcommand.ExecuteNonQuery();

}

-----------------------------------------------------------------------------------------

I've used parametric command, but it not seems helpful.
If anybody has any idea about this problem, please share with me. :)

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top