OpenSQL Help

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

psyXonova
Posts: 785
Joined: Fri May 20, 2005 3:57 am
Location: Nicosia, Cyprus
Contact:

OpenSQL Help

Post by psyXonova »

Ok, I have a very specific question about a problem that it gets on my nerves

Code: Select all

QSQL = "SELECT Playlists.ParentPlaylist FROM Playlists WHERE Playlists.PlaylistName = " & Chr(34) & "Last 50 Played" & Chr(34)
SDB.Database.OpenSQL(QSQL)

Why the spesific query returns an error? (Too few parameters, expected 1)
This query runs just fine from Inside Access

I know it has to do with the fact that Playlist.PlaylistName is a text field. But even if i replace "=" with "like" i get the same message
On the other hand if the WHERE clause is something like "WHERE Playlists.IDPlaylist = 1) it works just fine....

Plz help me

Thanks in advance
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

I dont know VBScript but wouldnt this work?

Code: Select all

QSQL = "SELECT Playlists.ParentPlaylist FROM Playlists WHERE Playlists.PlaylistName = 'Last 50 Played'"
SDB.Database.OpenSQL(QSQL) 
I mean why do you have Chr(34) in the code?

Or perhaps this one will work:

Code: Select all

QSQL = "SELECT Playlists.ParentPlaylist FROM Playlists WHERE Playlists.PlaylistName = " & Chr(34) & "'Last 50 Played'" & Chr(34)
SDB.Database.OpenSQL(QSQL) 
Peke
Posts: 18744
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

Becouse VBScript uses parenthals to determine String(Text) Type and Commands also needs Parenthals in String Parameters.

When Code Is executed it will look like this:

Code: Select all

QSQL = "SELECT Playlists.ParentPlaylist FROM Playlists WHERE Playlists.PlaylistName = "Last 50 Played""
SDB.Database.OpenSQL(QSQL)
and if you set script like that it will end up with Compile error.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

But isn't single quotes (') instead of dubble qoutes (") the proper workaround? I got that impression when I studied the sql in Magic Nodes!

/Bex
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

On the other hand it could be that you dont have a playlist named Last 50 Played. If Last 50 Played always has the IDPlaylist = 2, thats the id in my db, you could use that instead.

/Bex
trixmoto
Posts: 10023
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Can't you use...

Code: Select all

QSQL = "SELECT Playlists.ParentPlaylist FROM Playlists WHERE Playlists.PlaylistName = ""Last 50 Played"""
SDB.Database.OpenSQL(QSQL)
?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Peke
Posts: 18744
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

Trix Too many Delphi? :)
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
Steegy
Posts: 3450
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

In my (humble) opinion, Bex is right.

I always use:

Code: Select all

Set MyInfoNumber = SDB.Database.OpenSQL("SELECT Lists.ID FROM Lists WHERE TextData = '" & Name & "'")
BTW: Use ' ' for field contents, use [ ] for column names.
e.g.:

Code: Select all

... WHERE [COLUMN NAME] = 'just some text' ...
The ' ' obviously means the character is a text (string), so you can't use it with a numeric value (well, there's no need to; there are no spaces in a number).

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
psyXonova
Posts: 785
Joined: Fri May 20, 2005 3:57 am
Location: Nicosia, Cyprus
Contact:

Post by psyXonova »

Steegy, Bex
You are both right, that savved my problem, thank you very much

Trix
Your code produces the same error as mine.... Thanks for helping though

Peke
Your workaround doesnt offer much help to me since that name of the playlist will be a variable, i just mention last 50 played as an example

Thank you all guys, You have made my day!!!
Post Reply