i am trying to insert data inside a table but i keep on getting this exception:
A first chance exception of type 'Devart.Data.SQLite.SQLiteException' occurred in Devart.Data.dll
Parameter '18' is missing
here is my code:
Code: Select all
SQLiteConnection con = new SQLiteConnection();
SQLiteCommand cmd = new SQLiteCommand();
string dblocation = System.AppDomain.CurrentDomain.BaseDirectory;
dblocation = dblocation + @"test.s3db";
con.ConnectionString = @"Datasource=" + dblocation;
cmd.CommandText = "INSERT INTO ErrorLog(TheTimestamp,ErrorCategory,VariableValues,ExceptionOccured,FunctionName) VALUES(" + Convert.ToString(DateTime.Now) + "," + categoryString + "," + variablesValue + "," + Convert.ToString(theException) + "," + functionAndErrorPoint +")";
cmd.Connection = con;
con.Open();
try
{
rowsaffected = cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
return;
}
CREATE TABLE [ErrorLog] (
[ErrorId] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[TheTimestamp] DATE NOT NULL,
[ErrorCategory] NVARCHAR(50) NOT NULL,
[VariableValues] NVARCHAR(500) NOT NULL,
[ExceptionOccurred] NVARCHAR(500) NOT NULL,
[FunctionName] NVARCHAR(500) NOT NULL,
[ClientID] INTEGER NULL,
[Username] NVARCHAR(50) NULL
)
please help me out. what am i doing wrong here??? consider all variables and strings non-empty and declared. awaiting your replies.
regards