C
Colin Williams
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
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