C#在用VS和access数据库连接时出现一个错误无法找到表0.怎么解决啊,大神各位帮帮忙啊

public void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.yuangongxinxiDataSet1 = new personMIS.yuangongxinxiDataSet();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.yuangongxinxiDataSet1)).BeginInit();
this.SuspendLayout();
//

// yuangongxinxiDataSet1
//
this.yuangongxinxiDataSet1.CaseSensitive = true;
this.yuangongxinxiDataSet1.DataSetName = "yuangongxinxiDataSet";
this.yuangongxinxiDataSet1.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// BrowseJob
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(400, 270);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGrid1);
this.Name = "BrowseJob";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "工种种类浏览";
this.Closed += new System.EventHandler(this.BrowseJob_Closed);
this.Load += new System.EventHandler(this.BrowseSpecialtyl_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.yuangongxinxiDataSet1)).EndInit();
this.ResumeLayout(false);

}
#endregion
//定义数据集对象ds用于保存查询返回的结果集
DataSet ds;

ModifyJob modifyjob;
public void button2_Click(object sender, System.EventArgs e)
{
ds = new DataSet();
if (dataGrid1[dataGrid1.CurrentCell]!=null)
{
modifyjob=new ModifyJob();
modifyjob.Tag = ds.Tables[0].Rows[dataGrid1.CurrentRowIndex][0].ToString().Trim();
modifyjob.textBox1.Text = ds.Tables[0].Rows[dataGrid1.CurrentRowIndex][1].ToString().Trim();
modifyjob.textBox2.Text=ds.Tables[0].Rows[dataGrid1.CurrentRowIndex][2].ToString().Trim();
modifyjob.ShowDialog();

}
}

你的DS没有被FILL,就是说你的数据表没有被填充数据,在空的dataset 下,没有什麼任何表的。
另外,你有没有跟数据去要数据。眼拙没有看出来!
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-12-01
请仔细检查连接字符串数据库名称是否正确,查询语句表名是否正确
第2个回答  2012-12-01
表名错误
相似回答