2

can you please help me. I have created a table and now I want to generate the Update command with SQLiteCommandBuilder. But the Commandbuilder fails with Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information.

Im at a loss here, The Table has a primary key, and the Fill is working, giving me a Table with the 2 Fields. Its just the Commandbuilder thats failing me.

      string extStorage = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;

  string ProjectPath = Path.Combine(extStorage, "DBTEST");
  string dbFile = Path.Combine(ProjectPath, "TEST.DB");
  if (!Directory.Exists(ProjectPath)) {
    Directory.CreateDirectory(ProjectPath);
  }

  if (File.Exists(dbFile)) {
    File.Delete(dbFile);
  }
  SqliteConnection.CreateFile(dbFile);

  string my_Connection = string.Format("Data Source={0};Version=3;", dbFile);
  try {
    SqliteConnection my_DB_Con = new SqliteConnection(my_Connection);
    my_DB_Con.Open();
    SqliteCommand cmdCreate = new SqliteCommand("Create Table [T_RESULT] ( [LFDNR] int PRIMARY KEY not null, [TTT1] text);", my_DB_Con);
    cmdCreate.ExecuteNonQuery();

    SqliteCommand cmd = new SqliteCommand("select * from [T_RESULT]", my_DB_Con);
    SqliteDataAdapter my_adapter = new SqliteDataAdapter(cmd);
    DataSet ds = new DataSet();
    my_adapter.Fill(ds, "T_RESULT");

    SqliteCommandBuilder bld = new SqliteCommandBuilder(my_adapter);
    my_adapter.Fill(ds);

    my_adapter.UpdateCommand = bld.GetUpdateCommand(true);

    string text = my_adapter.UpdateCommand.CommandText;
  } catch (Exception exc) {
    string t = exc.Message;
  }

The Code throws at GetUpdateCommand.

The same Code works on Windows.

Can anyone help me here please.

ankuranurag2
  • 2,300
  • 15
  • 30
  • What do you mean "the same code works on Windows"? Can you show the exact code you ran on Windows? – Code-Apprentice Nov 02 '17 at 15:07
  • What does the error message say? – Alex Nov 02 '17 at 15:11
  • The my_adapter.UpdateCommand = bld.GetUpdateCommand(true); Line exits with the exception: Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information. – Sven Wittner Nov 02 '17 at 16:58
  • The Windows Code is exactly like this with different Path to the Database and the SQLite instead of Sqlite. That was just a Test if this Problem is in the Windows (PC) Version also, which isnt. – Sven Wittner Nov 02 '17 at 17:02

0 Answers0