SQL Statement - TechRepublic
General discussion
December 18, 2001 at 04:44 AM
afisher

SQL Statement

by afisher . Updated 24 years, 6 months ago

I have an app in VB 6 which uses an Access 2K backend. I have all of the latest service packs and MDAC updates installed. When I run the following SQL statement as a query within Access, I get one matching record:

SELECT dbo_Property.*, dbo_Apartment_For_SaleDetails.* FROM dbo_Property INNER JOIN dbo_Apartment_For_SaleDetails ON dbo_Property.PropertyID = dbo_Apartment_For_SaleDetails.PropID WHERE (((dbo_Property.Name) LIKE “*plaza*”));

When I use the following code from within my app, Iget no matching records with the above SQL statement:

Dim strConnStr As String

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset

strSQL = SQLStatement

strConnStr = “Provider=Microsoft.Jet.OLEDB.4.0;” & _
“Data Source=\\Hq_sql\Databases\CompData\Compdata.mdb;” & _
“Persist Security Info=False;”

cn.Open strConnStr

rs.CursorLocation = adUseClient

rs.Open strSQL, cn, adOpenForwardOnly, adLockPessimistic, adCmdText

I do get matching records with this code when using the following SQL statement:

SELECT dbo_Property.*, dbo_Apartment_For_SaleDetails.* FROM dbo_Property INNER JOIN dbo_Apartment_For_SaleDetails ON dbo_Property.PropertyID = dbo_Apartment_For_SaleDetails.PropID WHERE (((dbo_Property.ADNDataClassif) = 1));

This leads me to believe that the problem might be due to an incompatibility between the first SQL statement and the parameters I used while opening the connection and recordset objects.

Thanks in advance for your help!

This discussion is locked

All Comments