D
deko
I have a number of ComboBoxes that I need to change the DataSource of based
on user selection. I'm new to working with ADO, so I'm sure this is a very
basic question...
I want to pass in a string to switch on, and create a DataSet from a stored
procedure, like so:
private void GetCboData(string strCbo)
{
string strStoredProc = "";
OleDbConnection cnxOle = new OleDbConnection();
cnxOle.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Application.StartupPath +
@"\myAccessDb.mdb";
switch (strCbo)
{
case "Customer":
strStoredProc = "someStoredProc";
break;
case "Something Else":
strStoredProc = "someOtherStoredProc";
break;
case "Another Thing"
strStoredProc = "anotherStoredProc";
break;
}
OleDbCommand cmdOle = new OleDbCommand(strStoredProc, cnxOle);
OleDbDataAdapter daOle = new OleDbDataAdapter(cmdOle);
DataSet ds = new DataSet();
daOle.Fill(ds); //<<==== ??????? throws exception
this.cboProductColor.DataSource = ds;
}
How do I fill the DataSet in this scenario?
Thanks in advance.
on user selection. I'm new to working with ADO, so I'm sure this is a very
basic question...
I want to pass in a string to switch on, and create a DataSet from a stored
procedure, like so:
private void GetCboData(string strCbo)
{
string strStoredProc = "";
OleDbConnection cnxOle = new OleDbConnection();
cnxOle.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Application.StartupPath +
@"\myAccessDb.mdb";
switch (strCbo)
{
case "Customer":
strStoredProc = "someStoredProc";
break;
case "Something Else":
strStoredProc = "someOtherStoredProc";
break;
case "Another Thing"
strStoredProc = "anotherStoredProc";
break;
}
OleDbCommand cmdOle = new OleDbCommand(strStoredProc, cnxOle);
OleDbDataAdapter daOle = new OleDbDataAdapter(cmdOle);
DataSet ds = new DataSet();
daOle.Fill(ds); //<<==== ??????? throws exception
this.cboProductColor.DataSource = ds;
}
How do I fill the DataSet in this scenario?
Thanks in advance.