Data Binding of dataview is invalid within the using range.

Source: Internet
Author: User
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.