求大神指教 这样插入数据 为什么插不进去呢 用的是vs2010和Access2010
public OleDbConnection conInsert;
public OleDbCommand dCInsert;
public DataSet dSetInsert;
public string connstring = "Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=videoInformation.accdb";
public bool fnInsertData()
{
try
{
string strsql = "insert into tb_video(主持人,会议主题,会议主要内容,会议日期,开始时间,参加主要人员,存放位置)values(@MeetCompere,@MeetTopic,@MeetConnent,@MeetData,@MeetStartTime,@MeetParticipant,@MeetPath)";
conInsert = new OleDbConnection(connstring);
dCInsert = new OleDbCommand(strsql, conInsert);
dCInsert.Parameters.AddWithValue("@MeetCompere", MeetCompere);
dCInsert.Parameters.AddWithValue("@MeetTopic", MeetTopic);
dCInsert.Parameters.AddWithValue("@MeetConnent", MeetConnent);
dCInsert.Parameters.AddWithValue("@MeetData", MeetData);
dCInsert.Parameters.AddWithValue("@MeetStartTime", MeetStartTime);
dCInsert.Parameters.AddWithValue("@MeetParticipant", MeetParticipant);
dCInsert.Parameters.AddWithValue("@MeetPath", MeetPath);
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
//connectection failed
return false;
}
return true;
}
}
------解决方案--------------------
@MeetCompere->?
其它的自行修改
string strsql = "insert into tb_video(主持人,会议主题,会议主要内容,会议日期,开始时间,参加主要人员,存放位置)values(?,...)";
dCInsert.Parameters.AddWithValue("?", MeetCompere);