Link to home
Start Free TrialLog in
Avatar of al4629740
al4629740Flag for United States of America

asked on

error using datagrid in Windows 7

I am using a datagrid in VB6 which works fine in Windows XP.  However when I use the same datagrid in Windows 7 platform, I get the attached error.  There are two error pictures.  After I click OK on the first error, then the second error pops up.
file.doc
Avatar of Brook Braswell
Brook Braswell
Flag of United States of America image

Do you have the code behind this ?
Avatar of al4629740

ASKER

Yes!
Private Sub Command3_Click()

Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset

        If conn.State = adStateClosed Then
        conn.Open "Provider=sqloledb;Data Source=" & ConnectionIP & ",1433;Network Library=DBMSSOCN;Initial Catalog= CAPRegistration; User ID=xx;Password=xxxxxx"
        End If



esql = "Select Text22 as 'ID1', Text1 As 'ID2', Combo11 As 'Org', Text7 as 'Birthdate', Text4 As 'Last Name', Text5 As 'First Name', [CSW/TitleXX],EntryTime,Text8 As 'Address',Text9 as 'City',Text10 as 'Zip',Text11 as 'Phone'  from tblRegistration Where  Fiscal = '" & Fiscal & "'"

If rec.State = adStateOpen Then
        rec.Close
End If

      rec.CursorType = adOpenStatic
      rec.CursorLocation = adUseClient
      rec.LockType = adLockOptimistic
      rec.Open esql, conn, , , adCmdText


      
        Set DataGrid1.DataSource = rec
        
rec.MoveLast
        
        DataGrid1.Columns(0).Width = 350
        DataGrid1.Columns(1).Width = 750
        DataGrid1.Columns(7).Width = 2000
        
End Sub

Open in new window

I see that your source is based on a Connection IP...
Have you thought of changing this to be an Installed ODBC ?
Also...
I do not see the need in your statement to enclose the Alternate field in Quotes...
Private Sub Command3_Click()
        Set conn = New ADODB.Connection
        Set rec = New ADODB.Recordset
        If conn.State = adStateClosed Then
           conn.Open "Provider=sqloledb;Data Source=" & ConnectionIP & ",1433;Network Library=DBMSSOCN;Initial Catalog= CAPRegistration; User ID=xx;Password=xxxxxx"
        End If
        esql = "Select Text22 as ID1, Text1 As ID2, Combo11 As Org, Text7 as Birthdate, " & _
                      "Text4 As 'Last Name', Text5 As 'First Name', [CSW/TitleXX],EntryTime, " & _
                      "Text8 As Address, Text9 as City, Text10 as Zip, Text11 as Phone " & _
                 "FROM tblRegistration " & _
                "WHERE Fiscal = '" & Fiscal & "'"
        If rec.State = adStateOpen Then rec.Close
        rec.CursorLocation = adUseClient
        rec.Open esql, conn, adOpenStatic , adLockBatchOptimistic , adCmdText
        Set DataGrid1.DataSource = rec        
        if rec.recordcount > 0 then rec.MoveLast
        DataGrid1.Columns(0).Width = 350
        DataGrid1.Columns(1).Width = 750
        DataGrid1.Columns(7).Width = 2000
        
End Sub

Open in new window

I access this program over the internet

what alternate field are you talking about?  Is that the problem related to Windows 7?
SOLUTION
Avatar of Brook Braswell
Brook Braswell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I answered my own question