473,545 Members | 2,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What i missing!! please help. Insert query to Acces 2007

25 New Member
this is my query;
Expand|Select|Wrap|Line Numbers
  1. string NPI =                fields.GetValue(0).ToString();
  2.             string EntiType =           fields.GetValue(1).ToString();
  3.             string ProvLastNameLegal =  fields.GetValue(5).ToString();
  4.             string ProvFirsName =       fields.GetValue(6).ToString();
  5.             string ProvMiddName =       fields.GetValue(7).ToString();
  6.             string PromNamePref =       fields.GetValue(8).ToString();
  7.             string ProvNameSuffix =     fields.GetValue(9).ToString();
  8.             string ProvCredenText =     fields.GetValue(10).ToString();
  9.             try
  10.             {
  11.                 string query = "Insert INTO" + TableName + "(NPI, EntityTypeCode, ProviderLastNameLegalName, ProviderFirstName, ProviderMiddleName, ProviderNamePrefixText, ProviderNameSuffixText, ProviderCredentialText)"+
  12.                  "VALUES(@NPI, @EntityTypeCode, @ProviderLastNameLegalName, @ProviderFirstName, @ProviderMiddleName, @ProviderNamePrefixText, @ProviderNameSuffixText, @ProviderCredentialText)";
  13.                 String ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Gabiel\Documents\CMSProv.accdb; Persist Security Info=False";
  14.                 //@"Provider=Microsoft.Jet.4.0;Data Source=F:\CMSNPI\200910122000\CMSProv.mdb;User Id=admin;Password=;"; //ACCESS 2003
  15.                 OleDbConnection cn = new OleDbConnection(ConnectionString);
  16.                 OleDbCommand cmd = new OleDbCommand(query, cn);
  17.                 cmd.Parameters.AddWithValue("@NPI", NPI);
  18.                 cmd.Parameters.AddWithValue("@EntityTypeCode", EntiType);
  19.                 cmd.Parameters.AddWithValue("@ProviderLastNameLegalName)", ProvLastNameLegal);
  20.                 cmd.Parameters.AddWithValue("@ProviderFirstName", ProvFirsName);
  21.                 cmd.Parameters.AddWithValue("@ProviderMiddleName", ProvMiddName);
  22.                 cmd.Parameters.AddWithValue("@ProviderNamePrefixText", PromNamePref);
  23.                 cmd.Parameters.AddWithValue("@ProviderNameSuffixText", ProvNameSuffix);
  24.                 cmd.Parameters.AddWithValue("@ProviderCredentialText", ProvCredenText);
  25.                 cn.Open();
  26.                 cmd.ExecuteNonQuery();
  27.                 cn.Close();
  28.             }
  29.             catch (Exception ex)
  30.             {
  31.                 MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
  32.                 return;
  33.             }
  34.  
the following error ocurrer on this line: cmd.ExecuteNonQ uery();

{System.Data.Ol eDb.OleDbExcept ion: Syntax error in INSERT INTO statement.

at System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(OleDbHResult hr)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S dbParams, Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r behavior, Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior behavior, String method)
at System.Data.Ole Db.OleDbCommand .ExecuteNonQuer y()
at MCS_ImportTool. MCS_ImportTool. QueryImport(Str ing[] fields, String TableName) in C:\Users\Gabiel \Documents\Visu al Studio 2005\Projects\M CS_ImportTool\M CS_ImportTool\F orm1.cs:line 242}
Nov 21 '09 #1
2 1791
ThatThatGuy
449 Recognized Expert Contributor
Check out this part of the insert statement once again
Expand|Select|Wrap|Line Numbers
  1. "Insert INTO" + TableName + "(NPI, EntityTypeCode, ProviderLastNameLegalName
  2.  
there's no space between the INTO keyword and the table name:::: so that's the error point....
Nov 21 '09 #2
gabielmatos
25 New Member
Thanks i fix that peace of code but the error still theare!!
string query = " Insert INTO " + TableName + " (NPI, EntityTypeCode, ProviderLastNam eLegalName, ProviderFirstNa me, ProviderMiddleN ame, ProviderNamePre fixText, ProviderNameSuf fixText, ProviderCredent ialText) "+
" VALUES (@NPI, @EntityTypeCode , @ProviderLastNa meLegalName, @ProviderFirstN ame, @ProviderMiddle Name, @ProviderNamePr efixText, @ProviderNameSu ffixText, @ProviderCreden tialText)";
String ConnectionStrin g = @"Provider=Micr osoft.ACE.OLEDB .12.0;Data Source=C:\Users \Gabiel\Documen ts\CMSProv.accd b; Persist Security Info=False";
Ok i need to tell what the data i'm traying to insert to my access data base is from a .csv file. and each fields look like this ("\" 123467"\""")

thanks again for your helps
Nov 21 '09 #3

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

Similar topics

3
337
by: AMD Desktop | last post by:
Here is the table: CREATE TABLE ( IDENTITY (1, 1) NOT NULL , NOT NULL , NOT NULL , NOT NULL CONSTRAINT DEFAULT (0), NOT NULL , NOT NULL ) ON
2
1900
by: avinash | last post by:
hello myself avinash i am developing on application having vb 6 as front end and sql server 7 as back end. when i use insert query to insert data in table then the date value of that query is going as 01/01/1900 my query is as follows StrSql = "Insert Into...
4
18036
by: dcarson | last post by:
I've read about this error in several other discussions, but still can't seem to pinpoint the problem with my code. Everything seemed to be working fine for some time, but it now tends to bomb out on me for some reason. The Summary field is pulled from a Rich Text Editor that allows HTML formatting and appears to be the culprit, but I just...
8
6277
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with one-to-one relationship but on this occasion I must keep username/password details within a seperate table. Here's the basic specs and database schema:...
2
9028
by: sfrvn | last post by:
I am embarrassed to say I cannot make this work. Recently upgraded to Access 2003, but do not know if that part of problem (AKA 'syntax change'). Would someone be kind enough to lead me by the hand? Table name: LUtblProvider Table field names: provPKID, name, company, type, phone Table name: tblRef...
8
9395
by: Santy | last post by:
Hello All, I am new to DB2, Currently i am using DB2 version 8.02 personal edition on Windows XP Professional. And Facing problem with rowlock in insert query. I have created a sample database as CREATE TABLE SCEMANAME.LOG ( Sequence DECIMAL(9 ,0) NOT NULL ,
3
1362
by: BreckCogdill | last post by:
Hello, I'm trying to modify some code in simple Forum script - adding an ID field to an insert statement. I have added the field to the d/b & now I'm trying to add this new field to the existing INSERT INTO statement. I get the following error: Syntax error (missing operator) in query expression '1'Breck Cogdill''. Here's the block...
4
14988
by: thebarefootnation | last post by:
Hi I have the following error message "Syntax Error (missing operator) in query expression" occurring when I am trying to update combo box within a form. My code is: Dim strSQL As String
3
3290
by: Margie | last post by:
Working on my database I use a modified piece of code gotten from thescripts. The code works perfectly except for one thing. When entering data containing the character ' , I get the error: Syntac error (missing operator) in query expression. It took me a while but I discovered that entering the character ' twice in the form, it's added to the...
0
7499
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7432
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...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5359
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...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1919
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
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.