OpenSQL Help

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

Modérateurs : Peke, Gurus

psyXonova
Messages : 785
Inscription : ven. mai 20, 2005 3:57 am

OpenSQL Help

Message par psyXonova »

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

Code : Tout sélectionner

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
Messages : 6316
Inscription : ven. mai 21, 2004 5:44 am

Message par Bex »

I dont know VBScript but wouldnt this work?

Code : Tout sélectionner

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 : Tout sélectionner

QSQL = "SELECT Playlists.ParentPlaylist FROM Playlists WHERE Playlists.PlaylistName = " & Chr(34) & "'Last 50 Played'" & Chr(34)
SDB.Database.OpenSQL(QSQL) 
Peke
Messages : 18773
Inscription : mar. juin 10, 2003 7:21 pm

Message par 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 : Tout sélectionner

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
Messages : 6316
Inscription : ven. mai 21, 2004 5:44 am

Message par 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
Messages : 6316
Inscription : ven. mai 21, 2004 5:44 am

Message par 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
Messages : 10023
Inscription : ven. août 26, 2005 3:28 am

Message par trixmoto »

Can't you use...

Code : Tout sélectionner

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
Messages : 18773
Inscription : mar. juin 10, 2003 7:21 pm

Message par 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
Messages : 3450
Inscription : sam. nov. 05, 2005 7:17 pm

Message par Steegy »

In my (humble) opinion, Bex is right.

I always use:

Code : Tout sélectionner

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 : Tout sélectionner

... 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
Messages : 785
Inscription : ven. mai 20, 2005 3:57 am

Message par 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!!!
Répondre