OpenSQL Help

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

Moderatori: Peke, Gurus

psyXonova
Messaggi: 785
Iscritto il: ven mag 20, 2005 3:57 am

OpenSQL Help

Messaggio da psyXonova »

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

Codice: Seleziona tutto

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
Messaggi: 6316
Iscritto il: ven mag 21, 2004 5:44 am

Messaggio da Bex »

I dont know VBScript but wouldnt this work?

Codice: Seleziona tutto

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:

Codice: Seleziona tutto

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

Messaggio da 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:

Codice: Seleziona tutto

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
Immagine
Immagine
Immagine
How to attach PICTURE/SCREENSHOTS to forum posts
Bex
Messaggi: 6316
Iscritto il: ven mag 21, 2004 5:44 am

Messaggio da 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
Messaggi: 6316
Iscritto il: ven mag 21, 2004 5:44 am

Messaggio da 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
Messaggi: 10023
Iscritto il: ven ago 26, 2005 3:28 am

Messaggio da trixmoto »

Can't you use...

Codice: Seleziona tutto

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
Messaggi: 18773
Iscritto il: mar giu 10, 2003 7:21 pm

Messaggio da Peke »

Trix Too many Delphi? :)
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Immagine
Immagine
Immagine
How to attach PICTURE/SCREENSHOTS to forum posts
Steegy
Messaggi: 3450
Iscritto il: sab nov 05, 2005 7:17 pm

Messaggio da Steegy »

In my (humble) opinion, Bex is right.

I always use:

Codice: Seleziona tutto

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

Codice: Seleziona tutto

... 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
Messaggi: 785
Iscritto il: ven mag 20, 2005 3:57 am

Messaggio da 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!!!
Rispondi