B
Bennett Haselton
I know how to hook up an OleDbConnection, an OleDbDataAdapter, a
DataSet, and a DataView to a DataGrid named dgUserList at run time:
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C:\\shared\\test-database.mdb";
string strSQL = "SELECT username as uname, password as pword FROM
wbuser;";
DataSet objDataSet = new DataSet();
OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbDataAdapter objAdapter = new OleDbDataAdapter(strSQL,
objConnection);
objAdapter.Fill(objDataSet, "zquser");
DataView objDataView = new DataView(objDataSet.Tables["zquser"]);
dgUserList.DataSource=objDataView;
dgUserList.DataBind();
I'm trying to figure out how to do all of this at design time in VS
..Net 2002. I'm able to drop in the OleDbConnection object on the Web
Form and point it at the .mdb file. Then I'm able to create an
OleDbDataAdapter and when it asks me what data connection to use, I
specify the OleDbConnection representing the .mdb file and specify an
SQL query to get the data out of the table I want, and at the end, if
I press "preview data" it shows a table representing the data
correctly.
Also at design time, I can drop in a DataView called dvUserList and
then select the DataGrid and set the DataSource property to
dvUserList. I can also drop in a DataSet (called dsUnamesStuff) and
create a table in it called Table1, and then by selecting properties
of the DataView called dvUserList I can hit the "Table" dropdown and
it will show dsUnamesStuff->Table1 as a table that I can select.
The missing link is that I can't figure out how to bridge the gap
between the DataSet that is linked to my DataGrid, and the
OleDbDataAdapter that provides access to the data I want. I've taken
every line in the run-time code above, and found the design-time
equivalent, except for this one line:
objAdapter.Fill(objDataSet, "zquser");
Where in the design view of the adapter can I connect it to a table in
the dsUnamesStuff DataSet? If I select the dsUnamesStuff DataSet and
browse the "Tables" Collection properties, it lets me add and remove
new tables but it doesn't let me create any that are populated by the
OleDbDataAdapter. Or if I select the OleDbDataAdapter, I can't see
any editable properties that can connect it to the DataSet.
If anyone has time, I'm also confused about the "TableMappings" on the
OleDbDataAdapter. If I select the OleDbDataAdapter and click on the
button to edit its "TableMappings" properties, the dialog box that
opens says, "For each column in the source table, specify the name of
the corresponding column in the dataset table". What I don't
understand is what this sentence means by "the dataset". Since there
can be more than one DataSet declared in the code, and any of them can
be passed as an argument to the OleDbDataAdapter.Fill() method, what
does "the dataset" refer to at design time? Or does that just mean
that those column mappings will be applied whenever *any* DataSet is
passed at run time to the Fill() method.
Thanks very much for any help you have time to give me!
-Bennett
DataSet, and a DataView to a DataGrid named dgUserList at run time:
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C:\\shared\\test-database.mdb";
string strSQL = "SELECT username as uname, password as pword FROM
wbuser;";
DataSet objDataSet = new DataSet();
OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbDataAdapter objAdapter = new OleDbDataAdapter(strSQL,
objConnection);
objAdapter.Fill(objDataSet, "zquser");
DataView objDataView = new DataView(objDataSet.Tables["zquser"]);
dgUserList.DataSource=objDataView;
dgUserList.DataBind();
I'm trying to figure out how to do all of this at design time in VS
..Net 2002. I'm able to drop in the OleDbConnection object on the Web
Form and point it at the .mdb file. Then I'm able to create an
OleDbDataAdapter and when it asks me what data connection to use, I
specify the OleDbConnection representing the .mdb file and specify an
SQL query to get the data out of the table I want, and at the end, if
I press "preview data" it shows a table representing the data
correctly.
Also at design time, I can drop in a DataView called dvUserList and
then select the DataGrid and set the DataSource property to
dvUserList. I can also drop in a DataSet (called dsUnamesStuff) and
create a table in it called Table1, and then by selecting properties
of the DataView called dvUserList I can hit the "Table" dropdown and
it will show dsUnamesStuff->Table1 as a table that I can select.
The missing link is that I can't figure out how to bridge the gap
between the DataSet that is linked to my DataGrid, and the
OleDbDataAdapter that provides access to the data I want. I've taken
every line in the run-time code above, and found the design-time
equivalent, except for this one line:
objAdapter.Fill(objDataSet, "zquser");
Where in the design view of the adapter can I connect it to a table in
the dsUnamesStuff DataSet? If I select the dsUnamesStuff DataSet and
browse the "Tables" Collection properties, it lets me add and remove
new tables but it doesn't let me create any that are populated by the
OleDbDataAdapter. Or if I select the OleDbDataAdapter, I can't see
any editable properties that can connect it to the DataSet.
If anyone has time, I'm also confused about the "TableMappings" on the
OleDbDataAdapter. If I select the OleDbDataAdapter and click on the
button to edit its "TableMappings" properties, the dialog box that
opens says, "For each column in the source table, specify the name of
the corresponding column in the dataset table". What I don't
understand is what this sentence means by "the dataset". Since there
can be more than one DataSet declared in the code, and any of them can
be passed as an argument to the OleDbDataAdapter.Fill() method, what
does "the dataset" refer to at design time? Or does that just mean
that those column mappings will be applied whenever *any* DataSet is
passed at run time to the Fill() method.
Thanks very much for any help you have time to give me!
-Bennett