我正在尝试插入数据库 Ms Access 2007 。首先,我从文件夹中获取所有文件名,然后将该文件名复制到数据库中。这是我的数据库截图。
这是我的代码
string some = "Nothing";
Response.Write(v);
string[] filePaths = Directory.GetFiles(Server.MapPath("~/Gallery/GalleryImage/" + v));
int a =0;
OleDbCommand cmd = new OleDbCommand();
OleDbConnection mycon = new OleDbConnection();
mycon.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\AGENTJ.AGENTJ-PC\Documents\Visual Studio 2010\WebSites\mfaridalam\App_Data\mfaridalam1.accdb";
cmd = mycon.CreateCommand();
mycon.Open();
foreach (string item in filePaths)
{
a++;
string filename = Path.GetFileName(item);
string ips = 00 + a.ToString();
cmd.CommandText = "INSERT INTO [Image] ([Image],[Sort],[Created],[Albumid],[Description],[title])VALUES(" + filename + "," + ips + "," + some + "," +
v + "," + some + "," + some + ");";
int temp = cmd.ExecuteNonQuery();
if (temp > 0)
{
Response.Write("Writing is complete, Success!");
}
else
{
Response.Write("Application Error, Try Again!");
}
Response.Write(filename+ "<br/>");
}
mycon.Close();
cmd.Dispose();
mycon.Dispose();
我收到此错误
No value given for one or more required parameters.
在第 42 行: int temp = cmd.ExecuteNonQuery();