it is an access 2000 database.
here is the statement:
INSERT INTO Partyers (Sex, Last, First, CPhone, Phone,
City, BDay, Car, PicPath, FPotential, TPotential,
PartyCities) Values (False, '', '', '', '', '', '10/16/2004
12:17:22 AM', False, '', '', '', '')
when I use it from access, it goes file...
here is the code I use to Add it:
public static int ANum(String sql)
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString =
ConfigurationSettings.AppSettings["conString"];
OleDbCommand cmd = new OleDbCommand(sql,con);
con.Open();
cmd.ExecuteNonQuery();
string identity = "select @@identity";
cmd.CommandText = identity;
int id = (int)cmd.ExecuteScalar();
con.Close();
return id;
}
and the exception:
{"Syntax error in INSERT INTO statement."}
[System.Data.OleDb.OleDbException]: {"Syntax error in
INSERT INTO statement."}
Data: {System.Collections.ListDictionaryInternal}
HelpLink: null
InnerException: null
Message: "Syntax error in INSERT INTO statement."
Source: "Microsoft JET Database Engine"
StackTrace: " at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult
hr)\r\n at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)\r\n at
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)\r\n at
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)\r\n at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)\r\n at
System.Data.OleDb.OleDbCommand.ExecuteNonQuery()\r\n at
SQL.Connect.ANum(String sql) in f:\\my documents\\visual
studio\\projects\\connect\\connect.cs:line 63\r\n at
SQLStatements.PartiesDB.AddPartier(Boolean Sex, String
LName, String FName, String CPhone, String Phone, String
City, DateTime BDay, Boolean Car, String PicPath, String
PotentialClient, String PotentialTripper, String PCities)
in f:\\my documents\\visual
studio\\projects\\sqlstatements\\partiersdb.cs:line 20\r\n
at DataBase.Partyer
Update.Add() in F:\\My Documents\\Visual
Studio\\Projects\\Database\\PartyerUpdate.cs:line 35"
TargetSite: {Void
ExecuteCommandTextErrorHandling(System.Data.OleDb.OleDbHResult)}
thanks a lot in advance! (and to those that already responded!)
Kosta.
-----Original Message-----
kosta,
I would guess that there actually is something wrong with the statement,
or how you are executing it. Can you show the code that you have which is
trying to perform the insert?
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
hello! one of my forms communicates with a database, and is
supposed to add a row to a table using an Insert
statement... however, I get a 'oledb - syntax error'
exception... I have double checked, and the insert works
fine (tried to use it from access)... im using visual C#
express 2k5... what could be wrong? thanks!
.