读书人

OleDbDataReader dr = OleCmd.Execute

发布时间: 2012-01-03 22:16:06 作者: rapoo

OleDbDataReader dr = OleCmd.ExecuteReader(); 为何提示“至少一个参数没有被指定值” 代码如下:
代码:
string GetVirPath(string FullName)
{
FullName = FullName.Replace(Server.MapPath( "ValueExpression/ "), " ");
FullName = FullName.Replace( "\\ ", "/ ");
return FullName;
}

private void loadNotes(string path)
{
DirectoryInfo mainDir = new DirectoryInfo(path);
//try
//{
//Response.Write( " <B> " + mainDir.Name + " </b> <br/> ");
string dbProvider = System.Configuration.ConfigurationManager.AppSettings[ "dbProvider "];
string dbPath;
string ConnectionString;
OleDbConnection con;
dbPath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings[ "dbPath "]);
ConnectionString = dbProvider + "Data Source = " + dbPath;
con = new OleDbConnection(ConnectionString);
con.Open();
//遍历文件目录

foreach (FileInfo f in mainDir.GetFiles())
{
//增加文件GetVirPath(f.FullName)
//写入数据库

string cmdString = "select * from ValueProduce where FileName = ' " + GetVirPath(f.FullName) + " ' ";
OleDbCommand OleCmd = new OleDbCommand(cmdString, con);



OleDbDataReader dr = OleCmd.ExecuteReader();

dr.Read();
try
{
if (dr[1].GetType() != null)
{
continue;
}
}
catch
{
cmdString = "insert into ValueProduce (FileName) values ( ' " + GetVirPath(f.FullName) + " ') ";
OleCmd = new OleDbCommand(cmdString, con);
OleCmd.ExecuteNonQuery();
dr.Close();

}
}
con.Close();
}
// catch (Exception er)
// {
// Response.Write(er.ToString());
// }
//}

[解决办法]
try ->

string cmdString = "select * from ValueProduce where [FileName] = ' " + GetVirPath(f.FullName) + " ' ";


[解决办法]
断点跟一下

GetVirPath(f.FullName)看是否有值

读书人网 >asp.net

热点推荐