操作access数据库问题
本帖最后由 begun06081 于 2013-03-29 14:29:58 编辑
在学习oleDbCommand中
protected void Button1_Click(object sender, EventArgs e)
{
string myConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; data source=D:\\Visual Studio 2008\\WebSites\\UploadFileTest1\\App_Data\\media.mdb";
string myExecuteQuery = "insert into Media (test3,test4,test5,test6) values (@MName, @MUppath,MPlaypath,@MImgpath)";
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
OleDbCommand myCommand = new OleDbCommand(myExecuteQuery, myConnection);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
}
Media表是这样子的 MID 类型:自动编号 MName 类型:文本 MUppath 类型:文本 MPlaypath 类型:文本 MImgpath 类型:文本
然后就出错了
System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
OleDbCommand myCommand = new OleDbCommand(myExecuteQuery, myConnection);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
}
堆栈跟踪:
[OleDbException (0x80040e10): 至少一个参数没有被指定值。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +267
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +192
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +48
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +106
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +108
_Default.Button1_Click(Object sender, EventArgs e) in d:\Visual Studio 2008\WebSites\3-29\Default.aspx.cs:32
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
请问是什么原因出现了这样的错误
------解决方案-------------------- string myExecuteQu