Visual Basic Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘Environment’

BUG: Data Environment: MSHFlexGrid Rebinding Data

Symptoms
Attempting to rebind the MSHFlexGrid to a different Data Environment as theDataSource property results in an error:

Runtime Error 30022, The Hierarchical FlexGrid does not support therequested type of data binding.
Resolution
If the MSHFlexGrid.DataMember is set to a Data Environment other than theoriginal, the MSHFlexGrid attempts to rebind the data using the previousDataSource property setting. Because the same Command does not exist in thesubsequent Data Environment, an error results.

How To Specify a UDL File as the Source of Connection Attributes for a VB Data Environment Connection Object

Symptoms
Microsoft Data Links provide a simple interface to test an ActiveX Data Object (ADO) connection to a data source by using an OLEDB provider or an Open Database Connectivity (ODBC) driver. The connection information specified when setting up and testing an ADO connection using a data link is stored in a specified Universal Data Link (.udl) file. A .udl file can be specified as the source of connection attributes for an ADO Connection object by assigning the .udl file’s path to the “File Name” parameter in its ConnectionString property.
The Data Environment in Visual Basic 6.0 provides a graphical user interface (GUI) to set up ADO Connection and Command objects for use in a Visual Basic application. A Data Environment Connection object’s properties are typically set by navigating through a tabbed Properties dialog box and specifying the desired connection attributes like the OLE DB provider to use, the Database to connect to, the database user id and password, and so forth. A .udl file can also be used to specify the connection attributes for a Data Environment connection object. However, the Data Environment Connection object’s Properties dialog box does not provide an option to select a .udl file as the source of the connection attributes.
Resolution
To specify a .udl file as the source of connection attributes for a Data Environment connection object, you need to manually set the ConnectionSource property in its properties list box (accessed by selecting the Data environment connection object and pressing the F4 key).
The ConnectionSource property needs to be set to an ADO connection string of the format File name=<path to the .udl file>. For instance, assuming that you have a .udl file in the C:\ folder with the name of PUBS.UDL that connects to the SQL Server PUBS sample database, you would assign the following string to the ConnectionSource property of the Data Environment connection object to specify PUBS.UDL as the source of connection attributes:

File Name=C:\PUBS.UDL