Cannot initialize data bindings (datagrid won't load)-VBForums
Results 1 to 5 of 5

Thread: Cannot initialize data bindings (datagrid won't load)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2008
    Posts
    206

    Cannot initialize data bindings (datagrid won't load)

    Hi,

    I have been testing my program and all seems well. However, I sometimes get the error "Cannot initialize data bindings" when I try to sort (i.e. sort by first-name, last-name, address etc) a datagrid. The datagrid displays all customer information. I mainly get the error I thrash the program. Sometimes it runs okay. I don't see how the code can be wrong because it works 95% of the time. Perhaps a recordset is closed. I never get this error in VB6. Only in the application so I can't debug it via VB6.

    Thanks

    Simon
    Last edited by batman321; Nov 14th, 2009 at 01:40 AM.

  2. #2
    Lively Member
    Join Date
    Dec 2007
    Posts
    70

    Re: Cannot initialize data bindings (datagrid won't load)

    How do you organized your RecordSet?
    SELECT ???? FROM

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2008
    Posts
    206

    Re: Cannot initialize data bindings (datagrid won't load)

    Below is some of my code. Everything is declared. Like I said, it works 99% of the time. When I save records to the database, or delete an image, and go back to this button which is "sort records", it sorts records on the list option the user have chosen (i.e. firstname, lastname, address1 etc). The database path seems correct ( I checked it).


    Code:
     
    
    Dim adoConnection4 As ADODB.Connection
    Dim rs4 As ADODB.Recordset
    Dim connectString As String
    Dim esql4 As String
    Dim searchpattern1 As String
    Dim searchpattern As String
    Set adoConnection4 = New ADODB.Connection
    Set rs4 = New ADODB.Recordset
    
    rs4.CursorLocation = adUseClient
    
    If Search_Customers.Combo2.Text = "Search all Fields" Then
    
    searchpattern1 = """%" & Replace(Search_Customers.Text23.Text, """", """""") & "%"""
                        
    esql4 = "SELECT * FROM customers" _
              & " where title Like " & searchpattern1 & "" _
              & " or firstname Like " & searchpattern1 & "" _
              & " or lastname  Like " & searchpattern1 & "" _
              & " or address1 Like " & searchpattern1 & "" _
              & " or address2 Like " & searchpattern1 & "" _
              & " or city Like " & searchpattern1 & "" _
              & " or country Like " & searchpattern1 & "" _
              & " or postcode Like " & searchpattern1 & "" _
              & " or email Like " & searchpattern1 & "" _
              & " or homephone Like " & searchpattern1 & "" _
              & " or workphone Like " & searchpattern1 & "" _
              & " or mobilephone Like " & searchpattern1 & "" _
              & " or customerdob Like " & searchpattern1 & "" _
              & " or partnertitle Like " & searchpattern1 & "" _
              & " or partnerfirstname Like " & searchpattern1 & "" _
              & " or partnerlastname Like " & searchpattern1 & "" _
              & " or partneraddress1 Like " & searchpattern1 & "" _
              & " or partneraddress2 Like " & searchpattern1 & "" _
              & " or partnercity Like " & searchpattern1 & "" _
              & " or partnercountry Like " & searchpattern1 & "" _
              & " or partnerpostcode Like " & searchpattern1 & "" _
              & " or partneremail Like " & searchpattern1 & "" _
              & " or partnerhomephone Like " & searchpattern1 & " or partnerworkphone Like " & searchpattern1 & " Or PartnerMobilePhone Like " & searchpattern1 & " Or partnersdob Like " & searchpattern1 & " Or customerpartnernotes Like " & searchpattern1 & " Or CustomerTimeDateCreated Like " & searchpattern1 & " Or PartnerTimeDateCreated Like " & searchpattern1 & " Or customertimedateedited Like " & searchpattern1 & " Or partnertimedateedited Like " & searchpattern1 & " Or Image1 Like " & searchpattern1 & " Or Image2 Like " & searchpattern1 & " Or Image3 Like " & searchpattern1 & " Or Image4 Like " & searchpattern1 & " Or Image5 Like " & searchpattern1 & " Or Image6 Like " & searchpattern1 & " order by " & Search_Customers.Combo1.Text & ""
                                  
    rs4.Open (esql4), adoConnection4, adOpenDynamic, adLockOptimistic
    
    Set Search_Customers.SimplemodeSearchdatagrid.DataSource = rs4
    Search_Customers.SimplemodeSearchdatagrid.Refresh
    Search_Customers.SimplemodeSearchdatagrid.Rebind
    End If

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    37,202

    Re: Cannot initialize data bindings (datagrid won't load)

    Thread moved to 'Database Development' forum (the 'VB6' forum is only meant for questions which don't fit in more specific forums)

  5. #5
    Lively Member
    Join Date
    Dec 2007
    Posts
    70

    Re: Cannot initialize data bindings (datagrid won't load)

    Maybe it will help you.
    "Cannot initialize data bindings"
    www.vbforums.com/showthread.php?t=202470
    I think you should probably try replacing the "*" sign.
    Code:
    esql4 = "SELECT  [specify the field names] FROM customers" _

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.