Results 1 to 5 of 5

Thread: [RESOLVED] adodc connectionstring/recordsource problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Location
    Mucia, Sunny Spain
    Posts
    111

    Resolved [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?
    This question seems to have been asked before but without any meaningful (to me) resolution. Any offers?

    TIA

    Dave

  2. #2
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043

    Re: adodc connectionstring/recordsource problem

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3.     Adodc1.RecordSource = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Database.mdb"
    4.  
    5. End Sub
    oh1mie/Vic


  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: adodc connectionstring/recordsource problem

    VB Code:
    1. Private Sub Form_Load()
    2.     With Me.Adodc1
    3.         .ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=m:\testing\nwind2.mdb"
    4.         .CursorLocation = adUseClient
    5.         .CursorType = adOpenStatic
    6.         .LockType = adLockReadOnly
    7.         .CommandType = adCmdText
    8.         .RecordSource = "Select * From Customers"
    9.         'or
    10.         '.CommandType = adCmdTable
    11.         '.RecordSource = "Customers"
    12.     End With
    13.  
    14.     Set Me.DataGrid1.DataSource = Me.Adodc1
    15.  
    16. End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Location
    Mucia, Sunny Spain
    Posts
    111

    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Location
    Mucia, Sunny Spain
    Posts
    111

    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.

    Thank you Gentlemen

    Dave

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width