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 MaruthiRank #937 · 2.2K reputationPosted Jul 23, 2014, 7:38 AM EDT
Aditya PatilRank #2,485 · 565 reputationPosted Jul 23, 2014, 7:58 AM EDT
How I can solve this?
Ramesh MaruthiRank #937 · 2.2K reputationPosted Jul 23, 2014, 8:01 AM EDT
please see the difference i emitted the single quotes and added the comma after every column give a try in that way
Aditya PatilRank #2,485 · 565 reputationPosted Jul 23, 2014, 8:03 AM EDT
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 MaruthiRank #937 · 2.2K reputationPosted Jul 23, 2014, 8:06 AM EDT
Aditya PatilRank #2,485 · 565 reputationPosted Jul 23, 2014, 8:31 PM EDT
Please look to this problem too
Aditya PatilRank #2,485 · 565 reputationPosted Jul 23, 2014, 8:37 PM EDT
As where I used my old null variable so its not getting updated now its solved with my updated variable.
Thankx