this is my query; -
string NPI = fields.GetValue(0).ToString();
-
string EntiType = fields.GetValue(1).ToString();
-
string ProvLastNameLegal = fields.GetValue(5).ToString();
-
string ProvFirsName = fields.GetValue(6).ToString();
-
string ProvMiddName = fields.GetValue(7).ToString();
-
string PromNamePref = fields.GetValue(8).ToString();
-
string ProvNameSuffix = fields.GetValue(9).ToString();
-
string ProvCredenText = fields.GetValue(10).ToString();
-
try
-
{
-
string query = "Insert INTO" + TableName + "(NPI, EntityTypeCode, ProviderLastNameLegalName, ProviderFirstName, ProviderMiddleName, ProviderNamePrefixText, ProviderNameSuffixText, ProviderCredentialText)"+
-
"VALUES(@NPI, @EntityTypeCode, @ProviderLastNameLegalName, @ProviderFirstName, @ProviderMiddleName, @ProviderNamePrefixText, @ProviderNameSuffixText, @ProviderCredentialText)";
-
String ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Gabiel\Documents\CMSProv.accdb; Persist Security Info=False";
-
//@"Provider=Microsoft.Jet.4.0;Data Source=F:\CMSNPI\200910122000\CMSProv.mdb;User Id=admin;Password=;"; //ACCESS 2003
-
OleDbConnection cn = new OleDbConnection(ConnectionString);
-
OleDbCommand cmd = new OleDbCommand(query, cn);
-
cmd.Parameters.AddWithValue("@NPI", NPI);
-
cmd.Parameters.AddWithValue("@EntityTypeCode", EntiType);
-
cmd.Parameters.AddWithValue("@ProviderLastNameLegalName)", ProvLastNameLegal);
-
cmd.Parameters.AddWithValue("@ProviderFirstName", ProvFirsName);
-
cmd.Parameters.AddWithValue("@ProviderMiddleName", ProvMiddName);
-
cmd.Parameters.AddWithValue("@ProviderNamePrefixText", PromNamePref);
-
cmd.Parameters.AddWithValue("@ProviderNameSuffixText", ProvNameSuffix);
-
cmd.Parameters.AddWithValue("@ProviderCredentialText", ProvCredenText);
-
cn.Open();
-
cmd.ExecuteNonQuery();
-
cn.Close();
-
}
-
catch (Exception ex)
-
{
-
MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
-
return;
-
}
-
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}
2 1791
Check out this part of the insert statement once again -
"Insert INTO" + TableName + "(NPI, EntityTypeCode, ProviderLastNameLegalName
-
there's no space between the INTO keyword and the table name:::: so that's the error point....
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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...
|
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...
|
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:...
|
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...
| |
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 ,
|
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...
|
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
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |