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.ExecuteNonQuery();
{System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at MCS_ImportTool.MCS_ImportTool.QueryImport(String[] fields, String TableName) in C:\Users\Gabiel\Documents\Visual Studio 2005\Projects\MCS_ImportTool\MCS_ImportTool\Form1. cs:line 242}
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....
2 1781
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, 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";
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
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$) {
}
...
|
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...
|
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...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |