SQLiteDataAdapter and Fille to Dataset???

  • Shawn Anderson

    Shawn Anderson - 2004-05-07

    Does anyone know if this feature is supported?

    I am trying to run the following line of code:

    sqlDa.Update(dsResult, "SMTPEntry");

    But I am getting an exception.

    • Alexander Gavrilov

      It would be great if you'll post the real code what you're executing. And what exception are you getting?

      • Shawn Anderson

        Shawn Anderson - 2004-05-07

        The code is a little big to post :)

        Finisar.SQLite.SQLiteDataAdapter sqlDa = new Finisar.SQLite.SQLiteDataAdapter();

        sqlCmd.CommandText = "INSERT INTO SMTPLog (MailServerDNSName, ServerDomain, ClientIP) VALUES (@MailServerDNSName, @ServerDomain, @ClientIP, );";

        .... < a bunch more code > ...

        DataSet dsResult = new DataSet();

        dsResult.Tables["SMTPEntry"].Columns.Add(new DataRow("MailServerDNSName");
        dsResult.Tables["SMTPEntry"].Columns.Add(new DataRow("ServerDomain");
        dsResult.Tables["SMTPEntry"].Columns.Add(new DataRow("ClientIP");

        DataRow dr = dsResult.Tables["SMTPEntry"].NewRow();
        dr[0] = "sample";
        dr[1] = "sample";
        dr[2] = "sample";


        sqlDa.Update(dsResult);  <-- exception "Unknown"

        • Alexander Gavrilov

          As it turns out, the current version doesn't support Update method in DataAdapter. I'm trying to come up with the implementation today. You'll have to assign InsertCommand, UpdateCommand and DeleteCommand manually, as the current version will not support CommandBuilder as they are described here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconautomaticallygeneratedcommands.asp

          • Alexander Gavrilov

            SQLite.NET is supported DataAdapter.Fill and Update. Grab the version from CVS. See UnitTests/DataAdapterTests.cs for examples how it's supposed to work. The key here is to assign SourceColumn property for IDbDataParameter. SourceColumn is used to link IDbDataParameters in Insert/Update/DeleteCommand to DataRows changed in DataSet.

        • Tim McDaniel

          Tim McDaniel - 2004-05-07

          One thing I notice about this code is that it looks like you are trying to create a new table in the database by adding a table to the DataSet.  Maybe I misinterpret your intention.  However, ADO.NET does not support this method of creating tables.  You have to either explicitly set the UpdateCommand, InsertCommand, and DeleteCommand of the command object, or use a CommandBuilder to create them. SQLite.NET does not currently have a CommandBuilder implementation, which Alexander pointed out. 
          Also, according to the doc page that Alexander linked to, a CommandBuilder class only works with single tables, not Views generated from Joins of multiple tables.  Not sure if this fits your particular needs or not.

    • Shawn Anderson

      Shawn Anderson - 2004-05-14

      It works :) thanks...


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks