My Update Button Click C# Code to update SQLite Database
private void Update_Click(object sender, EventArgs e)
{
if(flag1==true)
{
try
{
// here we updating Notes i.e. Text Filed using Date filed. before that we have to check row present or not
var testdata = dbConn.Query
// Check result is empty or not
if (testdata == null)
MessageBox.Show("ID Not Present in DataBase");
else
{
var tp = dbConn.Query
+ "' Time='" + tpkDate.Value.Value.ToShortTimeString() //SQLite Exception coming at this stage as per SQLITE Exception message
+ "' Text='" + TextField.Text
+ "' Priority='" + ((ListBoxItem)priority.SelectedItem).Content.ToString()
+ "' where Id = '" + id + "'").FirstOrDefault();
//Here unhandled exception
// Update Database
dbConn.Update(tp);
Update_List();
MessageBox.Show("Database Updated");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
Task Class
public sealed class Task
{
///
/// You can create an integer primary key and let the SQLite control it.
///
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public String Date { get; set; }
public String Time { get; set; }
public string Text { get; set; }
public String Priority { get; set; }
}
Exception Messagebox Screenshot

Please solve my problem, may be syntax is wrong to set value of Time so please solve the time.

Ramesh MaruthiPosted Jul 23, 2014, 11:38 AM
Aditya PatilPosted Jul 24, 2014, 12:37 AM
As where I used my old null variable so its not getting updated now its solved with my updated variable.
Thankx
Aditya PatilPosted Jul 24, 2014, 12:31 AM
Please look to this problem too
Ramesh MaruthiPosted Jul 23, 2014, 12:06 PM
Aditya PatilPosted Jul 23, 2014, 12:03 PM
var tp = dbConn.Query
+ "', Time='" + tpkDate.Value.Value.ToShortTimeString() //SQLite Exception coming at this stage as per SQLITE Exception message
+ "', Text='" + TextField.Text
+ "', Priority='" + ((ListBoxItem)priority.SelectedItem).Content.ToString()
+ "' where Id = '" + id + "'").FirstOrDefault();
Its worked now. I think.
Ramesh MaruthiPosted Jul 23, 2014, 12:01 PM
please see the difference i emitted the single quotes and added the comma after every column give a try in that way
Aditya PatilPosted Jul 23, 2014, 11:58 AM
How I can solve this?