Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Change the DataSource at runtime

Total Hit ( 3800)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Visual Basic 6 is the first VB version that lets you programmatically change the DataSource property at runtime, for example to point to another ADO Data control or another ADO Recordset.

However, when you assign the new DataSource property VB immediately checks that the DataField and DataMember properties are valid. This means, for example, that if the new data source doesn't expose a field with the same name as the current value of the DataField property, you get error Error 545 - Unable to bind to field or DataMember: 'fieldname'.

Fortunately, you can work around this problem by simply setting the FieldName property to a null string before setting the DataSource property, and then assign it the new value:

Click here to copy the following block
' have Text1 point to another Data control
Text1.DataField = ""
Set Text1.DataSource = Adodc2
Text1.DataField = "City"


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.