473,657 Members | 2,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel sheet as Database, Why Does a apostrophe appear?

9 New Member
Hello I am using excel as my database and when I do an insert there is an apostrophe that appears in the cell where a string was inserted. For example '(474)343-3433

It appears that the apostrophe appears after an insert is done that with a null value.
example

(424)333-3433

'(474)343-3433
'(424)343-3333


thecode:

Expand|Select|Wrap|Line Numbers
  1. private void WriteToLeadTable()
  2. {
  3.  
  4.             // Establish a connection to the data source.
  5.             System.Data.OleDb.OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(
  6.                 "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_strSampleFolder +
  7.                 "LeadConsistencyScorecard.xls;Extended Properties=Excel 8.0;");
  8.             objConn.Open();
  9.  
  10.             // Add record
  11.             System.Data.OleDb.OleDbCommand objCmd = new System.Data.OleDb.OleDbCommand();
  12.             objCmd.Connection = objConn;
  13.  
  14.             /* The fallowing two fields will not be updated because we do not know what is up
  15.             * And it is up to the channel manager to know
  16.             * 
  17.             * Assigned_Date, Assigned_To_Position, Assigned_To_Name,"
  18.             * + "Status,
  19.              * + "', '" + Fields.Assigned_Date
  20.              * + "', '" + Fields.Assigned_To_Position    + "', '" + Fields.Assigned_To_Name  + "', '" + Fields.Status
  21.              * 
  22.             */
  23.  
  24.  
  25.             //Write to LeadTable
  26.             objCmd.CommandText = "INSERT into [Leads$] (Lead_ID, Event_ID, Lead_Comment_ID, Event_Name,"
  27.               + " Received_Date, Lead_Grade,"
  28.               + " Company_Name,"    +" Street_1,"  +" Street_2," +" Street_3,"        + " City,"
  29.               + " State,"           +" Zip_Code,"  +" Country,"  +" Company_Phone,"   + " Website,"
  30.               + " First_Name,"      +" Last_Name," +" Job_Title," + " Contact_Phone," + " Phone_Ext,"
  31.               + " Alternate_Phone," +" Email,"     +" Industry_Vertical)"
  32.               + " values ('" + Fields.Lead_ID   + "', '" + Fields.Event_ID          + "', '" + Fields.Lead_Comment_ID
  33.               + "', '" + Fields.Event_Name      + "', '" + Fields.Rainmaker_Date    + "', '" + Fields.Lead_Grade        
  34.               + "', '" + Fields.Company_Name    + "', '" + Fields.Street_1          + "', '" + Fields.Street_2 
  35.               + "', '" + Fields.Street_3        + "', '" + Fields.City              + "', '" + Fields.State
  36.               + "', '" + Fields.Zip_Code        + "', '" + Fields.Country           + "', '" + Fields.Company_Phone
  37.               + "', '" + Fields.Website         + "', '" + Fields.First_Name        + "', '" + Fields.Last_Name
  38.               + "', '" + Fields.Job_Title       + "', '" + Fields.Contact_Phone     + "', '" + Fields.Phone_Ext
  39.               + "', '" + Fields.Alternate_Phone + "', '" + Fields.Email             + "', '" + Fields.Industry_Vertical + "')";
  40.  
  41.               objCmd.ExecuteNonQuery();
  42.  
  43.             // Close the connection.
  44.               objConn.Close(); 
  45.         }
  46.  
  47.  
Jan 9 '08 #1
3 4917
pitchblack408
9 New Member
Take a look here if any one cares
Paul Clement
Posted: Tue Jun 28, 2005 8:12 am
Guest
On 28 Jun 2005 03:17:13 -0700, "Sam Jost" <samjost@web.de > wrote:

¤ I written myself some small generic class to export any dataset to an
¤ excel spreadsheet:
¤
¤ public static void Export(DataSet data, String excelFileName)
¤ {
¤ System.IO.File. Delete(excelFil eName);
¤ string strConnectionSt ring = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
¤ Source="
¤ + System.IO.Path. GetDirectoryNam e(excelFileName ) + @"\" +
¤ System.IO.Path. GetFileName(exc elFileName)
¤ + @";Extended Properties='Exc el 8.0;HDR=YES'";
¤
¤ using (System.Data.Ol eDb.OleDbConnec tion objConn = new
¤ System.Data.Ole Db.OleDbConnect ion(strConnecti onString))
¤ using (System.Data.Ol eDb.OleDbComman d cmd = new
¤ System.Data.Ole Db.OleDbCommand ("", objConn))
¤ {
¤ objConn.Open();
¤ foreach (DataTable dt in data.Tables)
¤ {
¤ cmd.CommandText = "CREATE TABLE [" + dt.TableName + "] (";
¤ String valueNames = "(";
¤ Boolean first = true;
¤ foreach (DataColumn dc in dt.Columns)
¤ {
¤ if (!first)
¤ {
¤ cmd.CommandText += ",\r\n";
¤ valueNames += ", ";
¤ }
¤ cmd.CommandText += " [" + dc.ColumnName + "] NVARCHAR(100)";
¤ valueNames += " [" + dc.ColumnName + "]";
¤ first = false;
¤ }
¤ cmd.CommandText += ")";
¤ valueNames += ")";
¤ cmd.ExecuteNonQ uery();
¤ foreach (DataRow dr in dt.Rows)
¤ {
¤ String values = "(";
¤ first = true;
¤ foreach (DataColumn dc in dt.Columns)
¤ {
¤ if (!first)
¤ values += ", ";
¤ values += " '" + dr[dc] + "'";
¤ first = false;
¤ }
¤ values += ")";
¤ cmd.CommandText = "INSERT INTO [" + dt.TableName + "$] " +
¤ valueNames + " VALUES " + values;
¤ cmd.ExecuteNonQ uery();
¤ }
¤ }
¤ }
¤ }
¤
¤ This does work quite ok for my uses, the only problem is: After export
¤ the first character in every single cell of the excel spreadsheet is
¤ the quotation mark '
¤ Somehow the export does not strip the leading quotation marks from my
¤ values - anyone can give me a hint how I do get rid of these?


That is the way the Excel ISAM driver was designed to work. It adds the apostrophe to discriminate
between text and numeric values. I don't believe it shows up in the cell, just the formula bar.


Paul
~~~~
Microsoft MVP (Visual Basic)
Back to top
Sam Jost
Posted: Tue Jun 28, 2005 8:43 am
Guest
My bad - is there any way to get rid of this 'Feature by design' so I
don't have these apostrophs in every cell?
Maybe using a different type instead of NVARCHAR for the field,
anything?

Thanks,
Sam
Jan 9 '08 #2
pitchblack408
9 New Member
I made sure that it always outputs a value. So if there in no value it will output null as the value. That gets rid of the extra charater
Jan 9 '08 #3
klatuvarata
1 New Member
It's a settings issue dealing with Lotus Notes
Go to
Tools-->Options-->Transition--> Clear the Transition Navigation keys box.

Wala!
Apr 13 '12 #4

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

Similar topics

0
1504
by: Iain Hosking | last post by:
I'm running Access 2002 (on W2K) and need to access a MySQL database. I've installed and configured the latest MySQL ODBC driver, and it works perfectly from Excel, but in Access 2002 the File->Get External Data->Link Tables->Files of Type list does not include ODBC databases. Interesting, it *does* include a 'type' of 'Registry Error (*.*)'. I've tried uninstalling and reinstalling Access to no avail. I can't find a
2
5687
by: Ian | last post by:
I have an Access97 database and I am trying to create an Excel sheet from a report within this database. I have the following code on the On Click event of a button on a form: ----------------------------------------------------- On Error GoTo ErrReport
1
2297
by: Vivek | last post by:
Hi all, I am trying to import data from an excel sheet to MSSQL server 2000 using a web application (C#). Since I have to validate the data in the excel sheet, the approach i have used is to get the data from the excel sheet in a datatable in my excel sheet. For this i have used an ODBC connection and selected the contents from my excel sheet. Through the data adapter got it into a datatable. CLOSED THE ODBC CONNECTION. Validated the...
14
5783
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the SQL DATABASE, probably by the click of a button. Is this possible? & what is the BEST APPROACH for doing this? & also if any links are there do tell those to me too coz I have no idea how to go about doing it.
9
22488
by: dba123 | last post by:
I need some help and direction on what classes and an example or two (article) on how to read an Excel Worksheet and insert one column into a database table column. I am using .NET 2.0 only. What namespaces and classes should I use and how? -- dba123
8
4604
by: hyper-sensitive | last post by:
Hi Can some body suggest me which approach I should follow to import millions of records from data base into an excel sheet? I am working with ver. 2000 of MS-Excel . The requirement is to dynamically load 65,000 rows to one excel-grid(worksheet) ,then create and load the other grids(worksheets) till the data has been loaded fully. How can I do this using the Filestream object ,in a very short span of time like some seconds? Here,...
2
2410
by: surekhads | last post by:
Hi all, I have developed a project for extracting data from a HTML file and export that data to a excel sheet. I am storing that extracted data to the db. And then I am exporting that data to excel sheet. But, the data is getting overwritten in that excel sheet each time. I want to get rowcount from excel sheet & then append new data to that sheet. I tried to connect to excel sheet as a database. But, after that I have no idea how to...
7
2438
by: eklavyavats | last post by:
I am able to import data from the database to excel sheet. But i was unable to load the data from the excel sheet to my sql.I have connected the excel sheet to my sql but the data that is imported to the database is corrupted as it is required to enter how the two data are seperated and how does the new line begins. I will b using the visual basic for this purpose. Can i get any sort of help
7
12060
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
1
1959
by: PeacefulSoul | last post by:
Hello, I have a lot of excel sheets which columns are slightly different, i want to import all of these sheets (one at a time) into ONE SQL TABLE. I'll give an example : Say ive written the required program and called it Excel2sql converter. So Excel2sql takes an excel sheet and create a database table with the data of that excel sheet, For example say i have the following excel sheet: Excel_Sheet_1 -----------------------------...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8516
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.