ODBC from a button in a form

Hi,I am developing a notes application using an SQL server database. In my form I need to compare the value of the particular field against SQL table field.

For example. I need to check whether the company name is found in the SQL table. If it exists then get the company phone number and add to the form. I would like to put a button in a form that will create an ODBC connection. How can I do this kind of search?

Thanks!!!

Subject: ODBC from a button in a form

Hello,

you should search this forum for “ODBC”…

But anyway: Here is some sample code (untested!)

Uselsx “*LSXODBC”

Dim conn As ODBCConnection

Dim query As ODBCQuery

Dim result As ODBCResultSet

Set conn = New ODBCConnection

Set query = New ODBCQuery

Set result = New ODBCResultSet

If(conn.ConnectTo(“MyDSN”)) Then

Set query.Connection = conn

Set result.Query = query

End If

query.SQL = “SELECT * FROM MyTable WHERE [MyKey] = ‘12345’”

Call result.Execute

If (result.IsResultSetAvailable) Then

...

End If

HTH

Kuwe