I'm trying to generate InsertCommand to SqliteDataAdapter but got this error:
Unhandled Exception:
System.InvalidOperationException: Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information.
This is my code:
using Mono.Data.Sqlite;
public void Test(){
var dataAdapter = new SqliteDataAdapter();
var dataSet = new DataSet("TestTable");
SqliteCommandBuilder commandBuilder = new SqliteCommandBuilder(dataAdapter);
SqliteConnection connection = new SqliteConnection();
connection.ConnectionString = "Data Source=" + dbPath;
connection.Open();
dataAdapter.SelectCommand = connection.CreateCommand();
//dataAdapter.SelectCommand.CommandText = "SELECT * FROM TestTable";
dataAdapter.SelectCommand.CommandText = "SELECT [ID], [Name] FROM TestTable";
dataAdapter.InsertCommand = commandBuilder.GetInsertCommand(); // ERROR
}
Create table script:
CREATE TABLE `TestTable` (
`ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`Name` TEXT NOT NULL
);
Data in table
1 'Pedro'
Any help?