Results 1 to 2 of 2

Thread: Method refresh of IAdodc failed

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2015
    Posts
    16

    Method refresh of IAdodc failed

    In fixing a VB application, the previous programmer in some instances used a SSOLEDBGRID to populate table data and the variable used to populate the grid was type ADODC.

    The ADODC variable has the following properties:
    Connection String: Provider=SQLNCLI11.1;Integrated Security=SSPI;Persist Security Info=False;User ID="";Initial Catalog=[Database Name];Data Source=[Server];Initial File Name="";Server SPN=""
    [I also tried "Provider=MSDASQL.1;Persist Security Info=False;Data Source=Reliant"]

    RecordSource is: "SELECT * FROM Configure"; the query has a command type of "adCommandUnknown"

    The error displayed on the screen occurs at ResultDC.Refresh when the View Results command button is clicked:
    Name:  VBError.gif
Views: 809
Size:  6.3 KB -- I abort the program at this time.

    When I inspect the properties if the GRID - the following errors are displayed:
    Name:  exclamationpoint.gif
Views: 715
Size:  2.7 KB -- after I click on "OK" the following appears:
    "Warning - the datasource property has not been set and/or the data control has not been configured correctly"


    The code behind the command button reads:
    Dim res As Boolean

    On Error GoTo cmdPerform_Click_Error

    res = C1Query.BuildSQL
    If res Then
    ResultDC.CommandType = adCmdText
    ResultDC.RecordSource = C1Query.SQL
    ResultDC.Refresh
    End If


    Any suggestions to fix this problem would be appreciated. Let me know if I need to provide additional information.

  2. #2
    Fanatic Member
    Join Date
    Apr 2015
    Location
    Finland
    Posts
    692

    Re: Method refresh of IAdodc failed

    You need to execute, instead of refresh...

    Code:
        Dim res As Boolean
        
      On Error GoTo cmdPerform_Click_Error
    
        res = C1Query.BuildSQL
        If res Then
            ResultDC.CommandType = adCmdText
            ResultDC.RecordSource = C1Query.SQL
            ResultDC.Refresh
        End If
    Code:
    'sSQL variable in this holds your query clause
    'Dim cmd As ADODB.Command
    Set cmd = New ADODB.Command
    
    With cmd
        .ActiveConnection = DB
        .CommandType = CommandTypeEnum.adCmdText
        .CommandText = sSQL
    End With
         
    Set RS = cmd.Execute(RecordsAffected)
    .
    .
    Set cmd.ActiveConnection = Nothing
    Set RS = Nothing

Tags for this Thread

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