AnsweredAssumed Answered

ODBC throwing exception in VB.Net

Question asked by AlastairMcInnes on Aug 27, 2012
Latest reply on Aug 30, 2012 by AlastairMcInnes


ODBC throwing exception in VB.Net



I'm using (visual studio express 2008, but also tried in 2003) to access Filemaker data in a Windows Form Application (Windows 7). I have created a simple app to demonstrate the problem. There is a single button and and a single listbox and the entirety of the program code is:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim conn As ADODB.Connection
        Dim rs As ADODB.Recordset

        conn = New ADODB.Connection
        conn.Open("DSN=TitlesUS_Triple8", "Username", "password")

        rs = New ADODB.Recordset
        rs.Open("SELECT Binding, SKU13, Contract_ID FROM ""US Titles"" WHERE Contract_ID > 1", conn)

        If Not rs.EOF Then

            Do While Not rs.EOF

        End If
    End Sub
End Class
The program throws an exception at the rs.MoveFirst() line. The exception error message is:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
If I take out the MoveFirst statement, the program works as intended and the listbox is populated with the contract IDs.
Obviously, I could just take out the MoveFirst statement, but it seems to me that there is something going wrong somewhere
and it's not wise to rely on it not poking its head up somewhere else.
When I ran the same program in VB.Net 2003, the error was that rs was not set to an instance of an object (despite 
the fact that the watch window was showing the values of some of the rs properties up to that point).
I'm using ADO 6.1 if that helps, but I've tried a couple of other version. The FM database is remotely hosted. If I use a 
local copy, I don't get the problem. 
I can't find anything on google which sounds similar so I'm hoping someone here has the answer.
Many thanks,