Link to home
Start Free TrialLog in
Avatar of ppmb
ppmb

asked on

DataControl.RecordSource= How to pass a SQL to MSSQL Server 6.5??

I have recently upsized the back end of my app from Access 97 to MSSQL Server 6.5. One DataControl originally has the following statement:
Data1.RecordSource="SELECT * FROM Staff WHERE StaffID='" & txtStaffID.Text & "'"
Data1.Refresh
However, it does not work with MSSQL Server 6.5 since it goes thru the ODBC layer. I read from "Help" and know that I can set the RecordSource = QueryDef.some_kind_of_property
to pass the SQL statement and then do the Refresh. But how??? Can anyone give me an example???
Avatar of clifABB
clifABB

The code you have will work.  You have another problem.
Let me clarify.

Your original code:
Data1.RecordSource="SELECT * FROM Staff WHERE StaffID='" & txtStaffID.Text & "'"

Is fully acceptable, even when you go through an ODBC layer.

Are you sure txtStaffID.Text contains data?
Are you sure the tables were rebuilt in SQLServer the same as they were in Access (table and field names the same)?

Are you getting any errors?

ASKER CERTIFIED SOLUTION
Avatar of Jagar
Jagar

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
Avatar of ppmb

ASKER

I read the comments from expert clifABB first and found out that it really is not the problem from the statement. Instead, it is from setup and the DBA. I am gonna credit clifABB the points but clifABB didn't have an answer for me to give points. How am I gonna do this???