Yes, 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.ExecuteCommandTextE rrorHandling(OleDbHResult
hr)\r\n at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult)\r\n at
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
executeResult)\r\n at
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult)\r\n at
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(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:lin e 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-----
Hi kosta,
Could you please post the sql statement. Which is the db
you are using - is it access?
Regards,
Rakesh Rajan
"kosta" wrote:
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!
.