473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ASP.NET C# and OLEDB.JET problem

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:

Expand|Select|Wrap|Line Numbers
  1. 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;\"");
  2. connect.Open();
  3. ...
  4. PushToXls("A", objDataset1.Tables[0].Rows[i][3].ToString(), objDataset1.Tables[0].Rows[i][4].ToString(), objDataset1.Tables[0].Rows[i][5].ToString(), connect);
  5. ...
  6. connect.Close();
  7.  
  8.  
  9. private void PushToXls(string table, string first, string second, string third, OleDbConnection connect)
  10.     {
  11.  
  12.             OleDbParameter pmfirst, pmsecond, pmthird;
  13.  
  14.  
  15.             if (first != "0")
  16.             {
  17.                 pmfirst = new OleDbParameter("@first", OleDbType.Numeric);
  18.                 pmfirst.Value = Convert.ToInt32(first);
  19.             }
  20.             else
  21.             {
  22.                 pmfirst = new OleDbParameter("@first", OleDbType.VarChar);
  23.                 pmfirst.Value = "";
  24.             }
  25.             if (second != "0")
  26.             {
  27.                 pmsecond = new OleDbParameter("@second", OleDbType.Numeric);
  28.                 pmsecond.Value = Convert.ToInt32(second);
  29.             }
  30.             else
  31.             {
  32.                 pmsecond = new OleDbParameter("@second", OleDbType.VarChar);
  33.                 pmsecond.Value = "";
  34.             }
  35.             if (third != "0")
  36.             {
  37.                 pmthird = new OleDbParameter("@third", OleDbType.Numeric);
  38.                 pmthird.Value = Convert.ToInt32(third);
  39.             }
  40.             else
  41.             {
  42.                 pmthird = new OleDbParameter("@third", OleDbType.VarChar);
  43.                 pmthird.Value = "";
  44.             }
  45.  
  46.             string insertCommStr = "INSERT INTO " + table + "tart VALUES (@first, @second, @third)";
  47.             OleDbCommand insertcommand = new OleDbCommand(insertCommStr, connect);
  48.             insertcommand.Parameters.Add(pmfirst);
  49.             insertcommand.Parameters.Add(pmsecond);
  50.             insertcommand.Parameters.Add(pmthird);
  51.  
  52.             insertcommand.ExecuteNonQuery();
  53.  
  54.     }
I've used parametric command, but it not seems helpful.
If anybody has any idea about this problem, please share with me. :)

Thanks.
Oct 4 '07 #1
1 1443
jhardman
3,406 Expert 2GB
HI and welcome to the scripts Developer Network. I have moved your post to the .NET forum (there is a technical difference between ASP and ASP.NET. The latter is a part of the .NET package and belongs here). I have also added code tags to your post to make it more readable. Please do this yourself in the future (notice the button marked - # -)

Jared, moderator
ASP forum
Oct 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Error while executing SP | last post by:
Hi, I am getting an error while executing a sp from Oracle database. Can you let me know what could be the problem? here is the code using(System.Data.OleDb.OleDbConnection cn = new...
3
by: Chris Thunell | last post by:
I have a program where i connect to an access database and get some information out of it. I'm using the oledb.3.51 version, my computer doesn't seem to have the 4.0 version, but the computer that...
1
by: N S S | last post by:
I Get the following Error ================ Error =============================== Procedure 'GetCetgoriesOrProducts' expects parameter '@CategoryID', which was not supplied. Description: An...
4
by: NS | last post by:
Hi, I am trying to execute a prepare statement using oledb provider for DB2. The command.Prepare() statement is giving me an exception " No error information available:...
2
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
7
by: aacool | last post by:
Hi, I've been trying to open an Excel connection through OLEDB with the code below: string ConnectString =@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + fileName.Text +...
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
1
by: EMW | last post by:
I use the following function to read an Excel worksheet into a dataset: Public Function GetDataFromExcel(ByVal FileName As String, ByVal ds As DataSet) As Boolean Try Dim strConn As String =...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
1
by: ErikJL | last post by:
I have a simple webservice that performs a SELECT query against a database, and then an INSERT statement on the same database/table. The problem arises at the time when we create the second OleDB...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.