Re: VB6 and SQL help needed
What is Table.Part in you query? Where is the Table table (bad nameing here) in the From clasue? What field is Filter in the table you are selecting from? The where condition for a Like search is:
Where FieldName LIKE = '%SomethingYouAreSearchingFor' (If a string) and you want the field to end with the search crieteria.
Re: VB6 and SQL help needed
Hey thanks for the reply
"Part" is a column in the database (see here: http://i45.tinypic.com/av4w87.jpg)
The "Table.Part" in my code was given to me by someone else to test, it diddn't work and i've now removed it.
The SQL now stands like this:
strSQL = "SELECT Part FROM Test_data WHERE Filter LIKE = '%ItemName'"
(Item name is a variable i have set in VB which = the text in the ""Item Catagory" List box
On run i get the following error:
Syntax error (Missing Operator) in query expression 'Filter LIKE = '%ItemName'
Re: VB6 and SQL help needed
OK then what is the column name you want to filter on (Filter?) that is the name that should go before the Like and Before the Where.
If ItemName is a var in your program it needs to be outside the sql string and not included but concatinated into the string.
Re: VB6 and SQL help needed
The column name is "part" (part number) i want to display only the part numbers where filter_1 matches the users selection.
ItemName is a variable in my VB Code... how do i use it in the sql string?
would it be easier if i just sent the project to you?
Re: VB6 and SQL help needed
I will not work on you package, but I will help you here.
Like this (find only where the entered data is at the end of the part field):
code Code:
strSQL = "SELECT Part FROM Test_data WHERE part LIKE = '%" & ItemName & "'"
Or Like this (find only where the entered data is at the start of the part field):
code Code:
strSQL = "SELECT Part FROM Test_data WHERE part LIKE = '" & ItemName &"%"
Or Like this (find any where the entered data in the part field):
code Code:
strSQL = "SELECT Part FROM Test_data WHERE part LIKE = '%" & ItemName &"%"
Re: VB6 and SQL help needed
getting syntax error (missing operator)
Re: VB6 and SQL help needed
IS the table named test_data or TestData? Do you want to filter on Filter_1 or Part? replace the appropriate values.
From you image it should be:
strSQL = "SELECT Part FROM Testdata WHERE Fitlter_1 LIKE = '%" & ItemName &"%'"
also What is what is the actual variable name
Re: VB6 and SQL help needed
The table is named: test_data
I want to filter on: filter_1
so i have this:
strSQL = "SELECT Part FROM Test_data WHERE filter_1 LIKE = '%" & ItemName & "%"
which still returns a syntax error
Re: VB6 and SQL help needed
You are missing a closing single qoute after the last wild card (%)
strSQL = "SELECT Part FROM Test_data WHERE filter_1 LIKE = '%" & ItemName & "%' "
Re: VB6 and SQL help needed
still same error on run :S
Re: VB6 and SQL help needed
Please post the exact sql that is being run. DO you know how to set break points? Watches?
Re: VB6 and SQL help needed
strSQL = "SELECT Part FROM Test_data WHERE filter_1 LIKE = '%" & ItemName & "%' "
and no i dont know how to set break points / watches?
Re: VB6 and SQL help needed
I want to see the actual sql generated not the code to build.
To be simple just add a textbox on the form and set the text to the sql statement
Re: VB6 and SQL help needed
sorry, i'm still (obviously) learning all this so please bare with me
text2.text = strSQL
gives the following:
Code:
SELECT filter from test_data
Re: VB6 and SQL help needed
so we cas see that the result you posted does not look like the code we were writing.
Now you need to set a break point in the code and step though the code line by line to see what is happing at each point.
You do that in the code module and click in the area on the left side of the code module (a grey line on the side of the white code wrting area) on a line at the start of the section you want to walk though. The application will stop running and show you the code window with the line highlighted. Now you use the F8 key to step to the next line of code. Check that the variables are setting to. The strSQL should look like the code we were writting above.
PS this is a very I repeat EXTREAMLY IMPORTANT concept to understand and get the ability to debug your code.