创建和添加参数时,大小和类型SqlDataAdapter
应该是什么?有没有必要的理由?Int
DateTime
size
adapter = new SqlDataAdapter();
adapter.InsertCommand = new SqlCommand(
"insert into MyTable (id, created, stuff) values (@id, @created, @stuff)",
connection);
adapter.InsertCommand.Parameters.Add("@id", SqlDbType.Int, ?????, "id");
adapter.InsertCommand.Parameters.Add("@created", SqlDbType.DateTime, ????, "created");
adapter.InsertCommand.Parameters.Add("@stuff", SqlDbType.VarChar, 250, "stuff");
添加以回答有关数据来源的问题:(在帖子的原始部分,我将“description”重命名为“stuff”)
public static DataSet dumpETEvents()
{
DataSet ret = new DataSet();
SQLiteDataAdapter adapter = new SQLiteDataAdapter();
adapter.SelectCommand = new SQLiteCommand(
"select id, created, description from ETEvents",
DbDatabase.connection);
adapter.MissingSchemaAction = MissingSchemaAction.Add;
adapter.AcceptChangesDuringFill = false;
adapter.Fill(ret);
return ret;
}