Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 1998-06-24
4
Medium Priority
?
152 Views
Last Modified: 2010-05-03
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???
0
Comment
Question by:ppmb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Expert Comment

by:clifABB
ID: 1464208
The code you have will work.  You have another problem.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1464209
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?

0
 
LVL 2

Accepted Solution

by:
Jagar earned 210 total points
ID: 1464210
If StaffID is an Autonumber field then take out the single quotes it should read
Data1.RecordSource="SELECT * FROM Staff WHERE StaffID= " & txtStaffID.Text

Like everyone said this SQL statement will work, but this looks to be your problem not the statement itself.
0
 

Author Comment

by:ppmb
ID: 1464211
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???
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question