Create a ledger for our house today Program You may encounter a Data Binding problem.
If dataview is used to obtain data within the using range, it cannot be bound to the control as a data source.
Details Code :
Using (dataview DV = _ myaccess. executedataview (commandtype. Text, strcommandtext ))
{
Combo. datasource = DV;
Combo. displaymember = strdisplay;
}
In this way, we can find that dateview can retrieve data and bind the data to the control, but there is no data in the drop-down box on the page.
However, with dataset, you can:
Using (Dataset DS = _ myaccess. executedataset (commandtype. Text, strcommandtext ))
{
Combo. datasource = Ds. Tables [0]. defaultview;
Combo. displaymember = strdisplay;
}
Or you can use dataview without using.
Dataview DV = _ myaccess. executedataview (commandtype. Text, strcommandtext );
Combo. datasource = DV;
Combo. displaymember = strdisplay;
Originally, dataview will be destroyed in time out of using, and the data bound to the control will disappear.
There are still many things you don't understand. Please advise.
1. Why does the bound data disappear?
2. What is exclusive using scope destroyed?