473,322 Members | 1,526 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,322 software developers and data experts.

Problem with an SQL command

devonknows
137 100+
If anyone can offer any advice on this i will be most grateful,

Ok im having trouble with an SQL Command, i have to assign the text from List2.Text into a LIKE section of my SQL statement.

Expand|Select|Wrap|Line Numbers
  1. statement = "SELECT Albumname, DIR, Mix FROM BonkersListAndDir WHERE Albumname LIKE '' ORDER BY Albumname"
That is the statment i am using, and next to the LIKE i have tried allsorts to inset the data for example

WHERE Albumname LIKE 'List2.Text'
WHERE Albumname LIKE '' & List2.Text
WHERE Albumname LIKE List2.text & ''

but also i need to add the % wildcard at the end of List2.text, ive also tried assigning List2.text to a var,

Expand|Select|Wrap|Line Numbers
  1.     Text = List2.Text & "%"
  2.    statement = "SELECT Albumname, DIR, Mix FROM BonkersListAndDir WHERE Albumname LIKE '' ORDER BY Albumname"
and inserting that between, before and after the '' symbols, but none of it seems to be going, al im getting is when i run it, that its an invalid SQL statement of some description, if anyone can help me, be most greatful. Thank you very much
Nov 30 '06 #1
1 1014
devonknows
137 100+
Sorry, My bad, didnt know wether that was supposed to be in the Mysql Section as it was actually mysql question lol, i just was in the Visual Basic part looking, but heres the code im working with in case any of you can help

Private Sub List2_Click()
If List2.ListIndex >= 0 Then
Dim db_file As String
Dim imagedir As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim statement As String
' Get the data.
db_file = App.Path
If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
db_file = db_file & "Data.mdb"

' Open a connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
conn.Open
Dim Text As String
Text = List2.Text & "%"
statement = "SELECT Albumname, DIR, Mix FROM BonkersListAndDir WHERE Albumname LIKE ' ' ORDER BY Albumname"
Set rs = conn.Execute(statement, , adCmdText)
Set DIRs = New Collection
Set MIX = New Collection
List1.Clear
Do While Not rs.EOF
List1.AddItem rs!MIX
DIRs.Add CStr(rs!Dir)
rs.MoveNext
Loop
rs.Close
conn.Close
imagedir = IMGs(List2.ListIndex + 1)
Image1.Picture = LoadPicture("" & imagedir)
Image1.Height = 1215
Image1.Width = 1215
End If
End Sub
Nov 30 '06 #2

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

Similar topics

38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
2
by: Xah Lee | last post by:
Python Doc Problem Example: os.system Xah Lee, 2005-09 today i'm trying to use Python to call shell commands. e.g. in Perl something like output=qx(ls) in Python i quickly located the...
3
by: Jagdip Singh | last post by:
Hi, We are facing problem accessing to DB2. Seems like database manager is down I tried starting it using db2start but it was neither showing any messages nor returning to command prompt...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
15
by: Ken Allen | last post by:
I have been developing a suite of assemblies over the past couple of weeks, and this afternoon somethign started misbehaving. If I do not run the IDE and compiler the code from the command line,...
7
by: WALDO | last post by:
I wrote a console application that basically consumes arguments and starts other command line apps via System.Process. Let's call it XCompile for now. I wrote a Visual basic add-in that does pretty...
0
by: Stewart Midwinter | last post by:
I have a Tkinter app running on cygwin. It includes a Test menu item that does nothing more than fetch a directory listing and display it in a Toplevel window (I'd use a tkMessageBox showinfo...
4
by: lynx_ace | last post by:
Hi everyone. I need a little bit help here...I have an assignment and it is working fine until the last part which I can't solve. So here's the code in simple form #define maxlength 200 ...
8
by: Ian Mackenzie | last post by:
Hi Guys I am VERY new to DB2 and have created a workingdays function to return the working days between 2 dates, but I get some compiler errors when running it: CREATE FUNCTION WORKINGDAYS...
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.