求各位牛人帮忙改改!!!一直报不支持“Provider ”,这是怎么回事???
//导入按钮
private void button1_Click(object sender, EventArgs e)
{
//获取文件路径
string filePath = this.textBox1.Text.Trim();
if (filePath != "")
{
if (filePath.Contains("xls"))//判断文件是否存在
{
InputExcel(filePath);
}
else
{
MessageBox.Show("请检查您选择的文件是否为Excel文件!谢谢!");
}
}
else
{
MessageBox.Show("请先选择导入文件后,再执行导入!谢谢!");
}
}
private void InputExcel(string pPath)
{
string conn = "Provider = Microsoft.Jet.OLEDB.12.0 ; Data Source =" + pPath + ";Extended Properties='Excel 12.0;HDR=False;IMEX=1'";
SqlConnection oleCon = new SqlConnection(conn);
oleCon.Open();
string Sql = "select * from [retrial]";
SqlDataAdapter mycommand = new SqlDataAdapter(Sql, oleCon);
DataSet ds = new DataSet();
mycommand.Fill(ds, "[retrial]");
oleCon.Close();
int count = ds.Tables["[retrial]"].Rows.Count;
for (int i = 0; i <&nb