1
当我想导入片擅长于C#应用程序的错误的出现,没有在表的一个或多个必需参数的给定值的Excel
ERROR为“没有对于给定的值的一个或多个必需参数” 。
我使用MS Excel的C#。这是我的代码
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.FileName = "";
openFileDialog1.Filter = "Excel File Sheet |*.xls; *.xlsx";
try
{
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string path = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + openFileDialog1.FileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;\";";
OleDbConnection conn = new OleDbConnection(path);
OleDbDataAdapter da = new OleDbDataAdapter("SELECT Date, PF, [Agent Name], TL, Supervisor, [Sum Under], [Sum Over], [Out of Adherence], Sch, Sum([Out of Adherence %]*100), Sum((100-(100*[Out of Adherence %]))) AS [Adherence % Daily] FROM [Sheet1$] GROUP BY Date, PF, [Agent Name], TL, Supervisor, [Sum Under], [Sum Over], [Out of Adherence], Sch, [Out of Adherence %]", conn);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
else
return;
}
catch(FieldAccessException ex)
{
MessageBox.Show("ERROR" + ex);
}
请帮我这个错误,
感谢所有..
什么样的错误?编译时间或运行时间?它出现在哪里?在这里检查一下 - http://stackoverflow.com/questions/2378763/no-value-given-for-one-or-more-required-parameters,然后检查你的代码是否为'Null'值。 – Vityata