I had code like this:
SQLiteCommand cmd = new SQLiteCommand( "INSERT
INTO UserRoles " +
"(UserName, Role) VALUES(@UserName,
@Role)", conn );
SQLiteParameter userParm = cmd.Parameters.Add(
"@UserName", DbType.String );
SQLiteParameter roleParm = cmd.Parameters.Add(
"@Role", DbType.String );
userParm.Value = username;
roleParm.Value = role;
cmd.ExecuteNonQuery();
I got an exception with a message of "near \"?\": syntax
error".
Rewriting the code to use unnamed parameters work.
Logged In: YES
user_id=1234220
I use named parameters in a different way and it works just
fine, code example below:
using(SQLiteCommand Cmd = Conn.CreateCommand())
{
Cmd.Parameters.Add("@strGroup", strGroup);
Cmd.Parameters.Add("@strLocation", strLocation);
Cmd.Parameters.Add("@dtStartDate", dtStartDate);
Cmd.Parameters.Add("@dtEndDate", dtEndDate);
Cmd.Parameters.Add("@dtStartLunch", dtStartLunch);
Cmd.Parameters.Add("@dtEndLunch", dtEndLunch);
Cmd.CommandType = CommandType.Text;
Cmd.CommandText = "INSERT INTO tblEvent"
+ " (strGroup, strLocation, dtStartDate, dtEndDate,
dtStartLunch,dtEndLunch)"
+ " VALUES (@strGroup, @strLocation, @dtStartDate,
@dtEndDate, @dtStartLunch, @dtEndLunch)";
int nResult = Cmd.ExecuteNonQuery();
}
Logged In: YES
user_id=526041
Could you provide samples of the data you are trying to insert?
And perhaps a stack trace of the error, if possible.
Thanks.
Logged In: YES
user_id=676362
Grrr, I tried to create a simple repro case, but was
unsuccessfull. Could have been something specific about the
data I was using at the time, but can't really remember what it
was now.