Помогите: вставка новой строки в БД

  • Автор темы DimkaYo
  • Дата начала
D

DimkaYo

#1
static public OleDbConnection YoConnection;
static public OleDbDataAdapter YoAdapter;

static public void DoConnection()

{


OleDbConnectionStringBuilder StrBld = new OleDbConnectionStringBuilder();

StrBld.Provider = "Microsoft.ACE.OleDb.12.0";
StrBld.DataSource = "AbleBeatBase.accdb";

YoConnection = new OleDbConnection(StrBld.ConnectionString);
YoConnection.Open();

}
static public void DoDataSet(ref DataSet TempDS, string TableName, string SqlString)
{
YoAdapter = new OleDbDataAdapter(SqlString + " " +TableName, YoConnection);



YoAdapter.Fill(TempDS, TableName);

}

static public void DoDataSet(ref DataSet TempDS, string TableName, string SqlString, string Uslovie)
{
string FullSql = SqlString + " " + TableName + " " + Uslovie;


OleDbDataAdapter YoAdapter = new OleDbDataAdapter(FullSql, YoConnection);

YoAdapter.Fill(TempDS, TableName);

}








OleDbParameterCollection pc;

DoConnection();

DataSet YoDataSet = new DataSet();

DoDataSet(ref YoDataSet, "MainMcInfo", "SELECT * FROM MainMcInfo");

YoAdapter.InsertCommand = YoConnection.CreateCommand();
YoAdapter.InsertCommand.CommandText = "INSERT INTO MainMcInfo" +
"(McID, ParentID, McName, Note, FinishDate, Bonus) VALUES" +
"(@McID, @ParentID, @McName, @Note, @FinishDate, @Bonus)";



pc = YoAdapter.InsertCommand.Parameters;

pc.Add("@McID", OleDbType.Integer, 0, "McID");
pc.Add("@ParentID", OleDbType.Integer, 0, "ParentID");
pc.Add("@McName", OleDbType.VarChar, 0, "McName");
pc.Add("@FinishDate", OleDbType.Date, 0, "FinishDate");
pc.Add("@Bonus", OleDbType.Integer, 0, "Bonus");





//OleDbCommandBuilder uuu = new OleDbCommandBuilder(YoAdapter);

DataRow NewRow = YoDataSet.Tables[0].NewRow();

NewRow[0] = 33;
NewRow[1] = 39;
NewRow[2] = "33";
NewRow[3] = "33";
NewRow[4] = DateTime.Parse("10.11.2454");
NewRow[5] = 987;


YoDataSet.Tables[0].Rows.Add(NewRow);



YoAdapter.Update(YoDataSet, "MainMcInfo");




Когда доходит до последней тсрочки апдейт. то выбрасывает "Ошибка синтаксиса в инструкции INSERT INTO"

Подскажите, пожалуйста!!! еуеуеу!!!