|
-
Jun 3rd, 2002, 06:37 AM
#1
Thread Starter
Junior Member
help in executing a query
Hi,
I was trying to list all details for names beginning with a particular character from the emp table in a data report. I am trying to pass this ename as a parameter from a textbox within a form. The query i wrote in the command was -
select * from emp where ename like '?%'
I have assigned the parameter fields as varchar in the parameters tab of the command object in the data environment.
The code for viweing the report is -
Private Sub Command1_Click()
If DataEnvironment1.rsCommand1.State = adStateOpen Then
DataEnvironment1.rsCommand1.Close
End If
DataEnvironment1.Command1 trim(Text1.Text)
Set DataReport1.DataSource = DataEnvironment1
DataReport1.Show
End Sub
Now when i enter S in the textbox and press the button, i get this error -
Run-time error 3708
Application defined or object defined error.
Any ideas how to fix this. The same query works in Oracle. Thanks.
-
Jun 3rd, 2002, 07:56 AM
#2
Fanatic Member
What database are you querying? Oracle?
When you say the same query works in Oracle, do you mean that you type "select * from emp where ename like 'S%'" into sqlplus and it works?
-
Jun 3rd, 2002, 09:13 AM
#3
Thread Starter
Junior Member
Re:query
Hi,
yeah exactly, the same query works in SQL* Plus, however I am unable to make this work in VB using the Data Environment.
-
Jun 3rd, 2002, 09:44 AM
#4
Fanatic Member
the reason is that msado puts the ' character in for you when you supply a varchar character. Try using this query:
Code:
select * from emp where ename like ? || '%'
The || is a concatenation in sql. Since you have specified that the ? is a varchar, you do not need to surround it with '.
-
Jun 3rd, 2002, 10:25 AM
#5
Thread Starter
Junior Member
Re:query
Hi,
thanks for your suggestion, tried it, but that didnt work to, it gives the same error. There must be some way around I guess.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|