TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aditya Patil
NA
535
134.1k
SQLite Exception in WIndows Phone app in C#
Jul 23 2014 8:08 AM
XAML Code
<toolkit:DatePicker Name="dpkDate" Margin="0,144,0,332" />
<toolkit:TimePicker Name="tpkDate" Margin="0,231,0,245" />
<!--<toolkit:ListPicker x:Name="priority" Margin="10,321,10,100" ExpansionMode="ExpansionAllowed" Background="#FFF7EBEB" SelectedIndex="0">-->
<ListBox HorizontalAlignment="Left" Height="103" VerticalAlignment="Top" Width="456" Name="priority" Margin="10,302,-10,0" >
<ListBoxItem x:Name="high" Content="High" Foreground="White" FontSize="24"/>
<ListBoxItem x:Name="medium" Content="Medium" Foreground="White" FontSize="24"/>
<ListBoxItem x:Name="low" Content="Low" Foreground="White" FontSize="24"/>
</ListBox>
<!--</toolkit:ListPicker>-->
<ListBox HorizontalAlignment="Left" Height="287" VerticalAlignment="Top" Width="456" Name="TaskListBox" Margin="10,302,-10,0" Visibility="Collapsed"/>
<TextBox HorizontalAlignment="Left" Height="134" Margin="0,5,0,0" TextWrapping="Wrap" Text="Write Note" VerticalAlignment="Top" Width="456" Name="TextField"/>
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<Task>("select * from task where Id='" + tempid + "'").FirstOrDefault();
// Check result is empty or not
if (testdata == null)
MessageBox.Show("ID Not Present in DataBase");
else
{
var tp = dbConn.Query<Task>("update task set Date= '" + dpkDate.Value.Value.ToShortDateString()
+ "' 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
{
/// <summary>
/// You can create an integer primary key and let the SQLite control it.
/// </summary>
[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.
Reply
Answers (
7
)
Multiple databases in single Entity Framework application
check box column in data grid view in winforms