Microsoft Jet 数据库引擎找不到对象'Score1'。请确定对象是否存在,并正确地写出它的名称和路径
publicDataSetCreateDataSource(){stringStrCon;//生成连接Excel数据表格的字符串StrCon="Provider=Micr...
public DataSet CreateDataSource()
{
string StrCon;
//生成连接Excel数据表格的字符串
StrCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Score.xls") + ";Extended Properties=Excel 3.0;";
OleDbConnection olecon = new OleDbConnection(StrCon); //定义OleDbConnection对象实例并连接Excel表格
OleDbDataAdapter myda = new OleDbDataAdapter("SELECT * FROM [Score1]", StrCon); //定义OleDbDataAdapter对象实例并调用Select查询语句提取Excel数据信息
DataSet myds = new DataSet();//定义数据集
myda.Fill(myds); //调用Fill方法
return myds;
}
protected void Read_Click(object sender, EventArgs e)
{
GridView1.DataSource = CreateDataSource();//绑定gridview
GridView1.DataBind();
}
请问怎么修改啊?? 展开
{
string StrCon;
//生成连接Excel数据表格的字符串
StrCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Score.xls") + ";Extended Properties=Excel 3.0;";
OleDbConnection olecon = new OleDbConnection(StrCon); //定义OleDbConnection对象实例并连接Excel表格
OleDbDataAdapter myda = new OleDbDataAdapter("SELECT * FROM [Score1]", StrCon); //定义OleDbDataAdapter对象实例并调用Select查询语句提取Excel数据信息
DataSet myds = new DataSet();//定义数据集
myda.Fill(myds); //调用Fill方法
return myds;
}
protected void Read_Click(object sender, EventArgs e)
{
GridView1.DataSource = CreateDataSource();//绑定gridview
GridView1.DataBind();
}
请问怎么修改啊?? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询