| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 188 人关注过本帖
标题:[求助]高手帮忙看看啊! 这一句总是说出现异常 myDataAdapter.Fill (ds,DataTableN
收藏  订阅  推荐  打印 
hyei1984
Rank: 1
等级:新手上路
帖子:30
积分:402
注册:2007-3-26
[求助]高手帮忙看看啊! 这一句总是说出现异常 myDataAdapter.Fill (ds,DataTableN

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;

namespace useDataGrid
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(64, 48);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(472, 160);
this.dataGrid1.TabIndex = 0;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(648, 269);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "使用DataGrid控件来显示数据";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\db1.mdb";

OleDbConnection myOleDbConnection= new OleDbConnection(connString);

string selectString = "SELECT * FORM 表1";

OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand ();

myOleDbCommand.CommandText = selectString;

OleDbDataAdapter myDataAdapter = new OleDbDataAdapter ();


myDataAdapter.SelectCommand = myOleDbCommand;


DataSet ds = new DataSet();
myOleDbConnection.Open ();
string DataTableName ="表1";
//ds.Clear ();
myDataAdapter.Fill (ds,DataTableName);

DataTable myDataTable = ds.Tables [DataTableName];


dataGrid1.DataSource = ds.DefaultViewManager;
}
}
}


这一句 出现异常 myDataAdapter.Fill (ds,DataTableName);
高手指教一下

[此贴子已经被作者于2007-3-28 22:42:37编辑过]

搜索更多相关主题的帖子: Fill  DataTableN  
2007-3-28 21:55
hyei1984
Rank: 1
等级:新手上路
帖子:30
积分:402
注册:2007-3-26

高手  99啊

2007-3-28 22:58
jacklee
Rank: 12Rank: 12Rank: 12
来自:宏杰技术
等级:贵宾
威望:32
帖子:1743
积分:18390
注册:2006-11-3

这种没有什么,找不到原因 就TRY一下再CATCH就出来结果了。

佛山宏杰技术!
2007-3-29 07:55
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.054944 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved