Hi Colin,
Here's a basic example (using a DataGridView) with comments:
// Declare the BindingSource variable
private System.Windows.Forms.BindingSource warehouseBindingSource;
// InitializeComponent method to add components to form
private void InitializeComponent()
{
//...
this.components = new System.ComponentModel.Container();
//...
// Create BindingSource and add to components
this.warehouseBindingSource = new
System.Windows.Forms.BindingSource(this.components);
// Initialize the component
((System.ComponentModel.ISupportInitialize)(this.warehouseBindingSource)).BeginInit();
// Assign BindingSource to DataGridView
this.warehouseGridView.BindingSource = this.warehouseBindingSource;
// Identify DataTable in DataSet to be bound to
this.warehouseBindingSource.DataMember = "Warehouse";
// Identify BindingSource (DataSet) to be bound to
this.warehouseBindingSource.DataSource = this.inventoryDataSet;
// End Initialization
((System.ComponentModel.ISupportInitialize)(this.warehouseBindingSource)).EndInit();
//...
}
// Form constructor method
public Form1()
{
//...
// Call InitializeComponent
InitializeComponent();
// ...
// Fill DataSet from TableAdapter
this.warehouseTableAdapter.Fill(this.inventoryDataSet.Warehouse);
//...
}
--
HTH,
Kevin Spencer
Microsoft MVP
Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net [quoted text, click to view] "Colin Williams" <colinwilliams399@msn.com> wrote in message
news:1181853679.188789.111100@o11g2000prd.googlegroups.com...
> Hi
>
> I have some paradox db's i need to connect to. I have figured out that
> i can do this using ODBC, however C# Express edition does not support
> this connectivity easily and must be done programmatically. I have a
> class to do this:
>
> public static class Data
> {
> public const string SelectAllCommandText = "select * from
> WindowInfo";
>
> public static string ConnectionString;
>
> public static DataSet GetWinInfoDataSet()
> {
> if (string.IsNullOrEmpty(ConnectionString))
> throw new ArgumentNullException("ConnectionString");
>
> DataSet result = new DataSet("WinInfo");
>
> using (OdbcConnection connection = new
> OdbcConnection(ConnectionString))
> {
> using (OdbcCommand command = new
> OdbcCommand(SelectAllCommandText))
> {
> command.Connection = connection;
> using (OdbcDataAdapter dataAdapter = new
> OdbcDataAdapter(command))
> {
> dataAdapter.Fill(result);
> connection.Close();
> }
> }
> }
> return result;
> }
> }
>
> Which seems OK.
> Need nelp on how to populate/bind a datagridview on my form. How can
> tweak the code below to do this?
>
> private void FormMain_Load(object sender, EventArgs e)
> {
>
> Data.ConnectionString = Settings.Default.ConnectionString;
>
> dataSet1 = Data.GetWinInfoDataSet();
> bindingSource1.DataSource =
> dataSet1.Tables["WindowInfo"] ;
> dataGridView1.DataSource = bindingSource1;
>
> }
>
>
> Many Thanks
>
> Colin Williams
>