473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

SQL Like Query with a variable as parameter in VB 6.0

Iam using SQL LIKE Query to add items run time to a combo Box.
I used the code as:

Dim EMPNAME As String
EMPNAME = TXTNAME.Text & "%"
Set RST = Nothing
Dim I As Integer
RST.Open "Select * from TAB_EMP_DETAILS where emp_name like '" &empname & "'", CON, 1, 2
I = 0
While Not RST.EOF
CMBNAME.AddItem RST("EMP_NAME"), I
CMBNAME.ItemData(I) = RST(0)
I = I + 1
RST.MoveNext
Wend
RST.Close

But the problem even though records are there it is showing EOF true and coming out of the loop without adding anything into combo box.

Please solve this problem urgently............................
Oct 27 '06 #1
2 6631
scripto
143 100+
Iam using SQL LIKE Query to add items run time to a combo Box.
I used the code as:

Dim EMPNAME As String
EMPNAME = TXTNAME.Text & "%"
Set RST = Nothing
Dim I As Integer
RST.Open "Select * from TAB_EMP_DETAILS where emp_name like '" &empname & "'", CON, 1, 2
I = 0
While Not RST.EOF
CMBNAME.AddItem RST("EMP_NAME"), I
CMBNAME.ItemData(I) = RST(0)
I = I + 1
RST.MoveNext
Wend
RST.Close

But the problem even though records are there it is showing EOF true and coming out of the loop without adding anything into combo box.

Please solve this problem urgently............................
Well, there's no way I can verify your SQL connection, so, assuming that your connection is valid and you did set RST as a ADODB.Recordset (it's currently set to nothing???), one possible problem COULD be that you have a space(s) in the textbox.
Give this a try:

EMPNAME = trim(TXTNAME.Text) & "%"
Oct 27 '06 #2
Killer42
8,435 Expert 8TB
Well, there's no way I can verify your SQL connection, so, assuming that your connection is valid and you did set RST as a ADODB.Recordset (it's currently set to nothing???), one possible problem COULD be that you have a space(s) in the textbox.
Give this a try:

EMPNAME = trim(TXTNAME.Text) & "%"
I find this surprising...
Expand|Select|Wrap|Line Numbers
  1. RST.Open "Select * from TAB_EMP_DETAILS where ...
I would have expected it to be done via the database.CreateRecordset method (or is it OpenRecordset?). On the other hand, there are so many different ways of doing these things...
Oct 28 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mike Cocker | last post by:
Hello, I'm quite weak at PHP, so I was hoping to get some help understanding the below code. First off, I'm trying to create a "query form" that will allow me to display the results on my...
5
by: Bruno Alexandre | last post by:
Hi guys, withou using SP, I want to be able to add a Parameter to the SQL Query and retrive the Recordset so I can use the Paging property under the recorset object.... how can I do this? I'm...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
5
by: MX1 | last post by:
Simpler way to ask question from my previous post. I wrote a query and it has a paramter field in it. I want to enter a date with the current year. If it I put in 6/30/2003, it works great. If I...
4
by: Judy | last post by:
I'm using Access 2003 and was wondering if it is possible to have a paramater selection within a crosstab query so that I wouldn't need to build a new table. I have a select query that I'm using...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
2
by: DanWeaver | last post by:
I am assigning a profile variable based on the conents of a text box when a button is pressed- this is then used as a search term to populate a list box- all controls are in same ajax update panel-...
10
by: Lloyd Harold | last post by:
I'm very new to PHP and attempting to put together a simple script for retrieving MySQL data of personal records. The MySQL table I'm using consists of: 0: id 1: name 2: location (an integer...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
20
by: raylopez99 | last post by:
Inspired by Chapter 8 of Albahari's excellent C#3.0 in a Nutshell (this book is amazing, you must get it if you have to buy but one C# book) as well as Appendix A of Jon Skeet's book, I am going...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.