DataSet basics - How to fill from stored proc?
- From: "deko" <deko@xxxxxxxxxx>
- Date: Tue, 12 Jul 2005 00:05:58 GMT
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.
.
- Follow-Ups:
- RE: DataSet basics - How to fill from stored proc?
- From: Elton W
- RE: DataSet basics - How to fill from stored proc?
- Prev by Date: Record index from DataRowView object
- Next by Date: Connect to remote xls via odbc and dsn
- Previous by thread: Record index from DataRowView object
- Next by thread: RE: DataSet basics - How to fill from stored proc?
- Index(es):
Relevant Pages
|