Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
chonthy
Starting Member
1 Post |
Posted - 2007-10-04 : 05:02:09
|
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[i][3].ToString(), objDataset1.Tables[0].Rows[i][4].ToString(), objDataset1.Tables[0].Rows[i][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. |
|
|
|
|
|
|