How to Convert using of SqlLit to Simple SQL command in C#

Posted by Nasser Hajloo on Stack Overflow See other posts from Stack Overflow or by Nasser Hajloo
Published on 2010-04-04T08:50:14Z Indexed on 2010/04/04 8:53 UTC
Read the original article Hit count: 521

Filed under:
|
|

I want to get start with DayPilot control I do not use SQLLite and this control documented based on SQLLite.

I want to use SQL instead of SQL Lite so if you can, please do this for me.

main site with samples http://www.daypilot.org/calendar-tutorial.html

The database contains a single table with the following structure

CREATE TABLE event (  id VARCHAR(50),  name VARCHAR(50),  eventstart DATETIME,  eventend DATETIME);

Loading Events

  private DataTable dbGetEvents(DateTime start, int days)    {
     SQLiteDataAdapter da = new SQLiteDataAdapter("SELECT [id], [name], [eventstart], [eventend] FROM [event] WHERE NOT (([eventend] <= @start) OR ([eventstart] >= @end))", ConfigurationManager.ConnectionStrings["db"].ConnectionString);
    da.SelectCommand.Parameters.AddWithValue("start", start);
    da.SelectCommand.Parameters.AddWithValue("end", start.AddDays(days));
    DataTable dt = new DataTable();
    da.Fill(dt);
    return dt;
  }

Update

  private void dbUpdateEvent(string id, DateTime start, DateTime end)    {
    using (SQLiteConnection con = new SQLiteConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString))
    {
        con.Open();
        SQLiteCommand cmd = new SQLiteCommand("UPDATE [event] SET [eventstart] = @start, [eventend] = @end WHERE [id] = @id", con);
        cmd.Parameters.AddWithValue("id", id);
        cmd.Parameters.AddWithValue("start", start);
        cmd.Parameters.AddWithValue("end", end);
        cmd.ExecuteNonQuery();
    }
  }

© Stack Overflow or respective owner

Related posts about sqllite

Related posts about sql