本文整理汇总了C#中System.Data.Odbc.OdbcDataAdapter类的典型用法代码示例。如果您正苦于以下问题:C# OdbcDataAdapter类的具体用法?C# OdbcDataAdapter怎么用?C# OdbcDataAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OdbcDataAdapter类属于System.Data.Odbc命名空间,在下文中一共展示了OdbcDataAdapter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetDataSetFromAdapter
public DataSet GetDataSetFromAdapter(
DataSet dataSet, string connectionString, string queryString)
{
using (OdbcConnection connection =
new OdbcConnection(connectionString))
{
OdbcDataAdapter adapter =
new OdbcDataAdapter(queryString, connection);
// Open the connection and fill the DataSet.
try
{
connection.Open();
adapter.Fill(dataSet);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// The connection is automatically closed when the
// code exits the using block.
}
return dataSet;
}
开发者ID:.NET开发者,项目名称:System.Data.Odbc,代码行数:24,代码来源:OdbcDataAdapter
示例2: new OdbcDataAdapter(String sql, OdbcConnection con);
//引入命名空间
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.Odbc;
public class MainClass : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
public MainClass()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(0, 8);
this.dataGrid1.Size = new System.Drawing.Size(376, 288);
this.dataGrid1.TabIndex = 0;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(384, 302);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.dataGrid1});
this.Load += new System.EventHandler(this.MainClass_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.Run(new MainClass());
}
private void MainClass_Load(object sender, System.EventArgs e)
{
string connectionString = @"Driver={MySQL};SERVER=localhost;DATABASE=NorthwindMySQL;";
OdbcConnection conn= new OdbcConnection(connectionString);
conn.Open();
OdbcDataAdapter da = new OdbcDataAdapter ("SELECT CustomerID, ContactName, ContactTitle FROM Customers", conn);
DataSet ds = new DataSet("Cust");
da.Fill(ds, "Customers");
dataGrid1.DataSource = ds.DefaultViewManager;
conn.Close();
}
}
开发者ID:C#程序员,项目名称:System.Data.Odbc,代码行数:60,代码来源:OdbcDataAdapter
注:本文中的System.Data.Odbc.OdbcDataAdapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论