Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh Method of ADODC ignores new value of ConnectionString Property 1

Status
Not open for further replies.

jerjim

Programmer
Jan 4, 2001
85
PH
Let me restate my previous question succintly.

I have a data control whose ConnectionString property was of course set at design time. I now set the ConnectionString property at runtime
with a new value and then call the refresh method, like this.

With adodc
.ConnectionString = new value of connection string
.Refresh
end with

The Refresh method looks for the old value of the connection string property.
Even though, when I checked in the debugger, the Connection string is set to the new value.

SO WHAT IS THE CORRECT PROCEDURE FOR SETTING THE CONNECTION STRING PROPERTY OF AN ADO DATA CONTROL AT RUNTIME.

 
I was using Microsoft ADO Data Control 6.0 (OLEDB) and it worked fine, the connection string is set immediately though you do not need refresh. You need to refresh if the RecordSource property is changed.
Try to set a valid RecordSource property before refreshing.

Private Sub Command1_Click()
Debug.Print Adodc1.ConnectionString
Adodc1.RecordSource = "select * from muziek"
Adodc1.Refresh
Adodc1.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=muziek.mdb;"
Debug.Print Adodc1.ConnectionString
End Sub

Private Sub Form_Load()
Adodc1.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=d:\muziek.mdb;"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top