[RESOLVED] adodc connectionstring/recordsource problem
I’ve got a little project that displays data on a DataGrid. (I think that the whole thing was copied from a MS example in the first place although I can’t find the source now…) The DataSource (of the DataGrid) is an adodc control. How do I change the adodc’s connectionstring and recordsource at runtime?
Is it even possible? :confused:
This question seems to have been asked before but without any meaningful (to me) resolution. :blush: Any offers?
TIA
Dave
Re: adodc connectionstring/recordsource problem
VB Code:
Private Sub Form_Load()
Adodc1.RecordSource = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Database.mdb"
End Sub
Re: adodc connectionstring/recordsource problem
VB Code:
Private Sub Form_Load()
With Me.Adodc1
.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=m:\testing\nwind2.mdb"
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.CommandType = adCmdText
.RecordSource = "Select * From Customers"
'or
'.CommandType = adCmdTable
'.RecordSource = "Customers"
End With
Set Me.DataGrid1.DataSource = Me.Adodc1
End Sub
Re: adodc connectionstring/recordsource problem
Thanks for that but ... do I still have to point the adodc's connectionstring/recordsource at a dummy db at design time? I've only got one PC working at the moment (so I can't test it) but would the compiled executable run on another machine if the dummy db wasn't there? It might seem like a stupid question but I don't want to spend too much time on this approach if it's fundamentally flawed.
Dave
Re: adodc connectionstring/recordsource problem
Ahhhh, now I understand - the way to do it is to not assign the connectionstring, etc., in the first place and to do the binding at runtime. :rolleyes:
Thank you Gentlemen :)
Dave