SDB.Database.QuerySongs

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

Moderators: Peke, Gurus

Anubis
Posts: 439
Joined: Fri Feb 04, 2005 4:57 pm
Location: Sydney, Australia

SDB.Database.QuerySongs

Post by Anubis »

I am starting to learn VBScripting and MM. Bare with me, I really don't know VBScript, but I do know non-object based programming, I just need a little helping hand...

I don't understand how to access the results of a SDB.Database.QuerySongs command.

Here is a code segment...

Code: Select all

    MsgBox(itm.Title)
    Set iter = SDB.Database.QuerySongs("AND SongTitle='" & itm.Title & "'")
    if iter.EOF then
       MsgBox("No title found")
    else
       MsgBox("Found at least one...")
    end if
I get the "Found" msg when I run my code, what I don't know is how to access the results of the QuerySongs command. As a starting point I'd like to do MsgBox(iter.Artist) or some such command to see the artist (and album) of the song I have found.

Can anybody help out here?

Thanks
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Re: SDB.Database.QuerySongs

Post by onkel_enno »

Code: Select all

    MsgBox(itm.Title)
    Set iter = SDB.Database.QuerySongs("AND SongTitle='" & itm.Title & "'")
    if iter.EOF then
       MsgBox("No title found")
    else
       while not iter.eof
              Msgbox(iter.item.artist)
              iter.next
       wend
    end if
Not tested!
Anubis
Posts: 439
Joined: Fri Feb 04, 2005 4:57 pm
Location: Sydney, Australia

Re: SDB.Database.QuerySongs

Post by Anubis »

onkel_enno wrote:

Code: Select all

Msgbox(iter.item.artist)
Not tested!
When I use this, I get the following error...

Code: Select all

Error #438 - Microsoft VBScript runtime error
Object doesn't support this property or method
There must be a different way to refer to the artist and album information.

Any other suggestions?
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

Sorry, not artist but artistname. Artist is the Artist-Object!
Anubis
Posts: 439
Joined: Fri Feb 04, 2005 4:57 pm
Location: Sydney, Australia

Post by Anubis »

onkel_enno wrote:Sorry, not artist but artistname. Artist is the Artist-Object!
Your a LEGEND!
I feel so embarrassed that I didn't work this out myself.
I think I'm on track now.
If I have any more questions, I know where to come!
Thanks
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

Anubis wrote: If I have any more questions, I know where to come!
You're welcome :D
hh_perth
Posts: 9
Joined: Thu Jun 09, 2011 8:23 am

Re: SDB.Database.QuerySongs

Post by hh_perth »

Although this topic may be outdated – I couldn’t find an answer anywhere else :
with a large database of songs I like to check / manipulate tags by applying VBA-EXCEL macros.
With SDB = CreateObject("SongsDB.SDBApplication") access works great in MM4
(with change SDB = CreateObject("SongsDB5.SDBApplication" unfortunately it does not work in MM5)
manipulating selected songs.
Problem: I want to check, whether a song “Artist – Title” already exists any how many (with what quality (bitrate) and length and where stored (path)).
With trying QuerySongs or OpenSQL both did not work properly, as a I was not able to formulate a direct search with
Artist & Title.

Set objSongListiterator = SDB.Database.QuerySongs("SongLength > 6*1000")

While Not objSongListiterator.EOF
Set objSongData = objSongListiterator.Item
If LCase(objSongData.artistname) = N_Artist And LCase(objSongData.title) = N_Title Then _
ActiveCell.Offset(i, 0) = objSongData.artistname: _
ActiveCell.Offset(i, 1) = objSongData.title: _
ActiveCell.Offset(i, 2) = objSongData.Path: _
ActiveCell.Offset(i, 3) = i & " of " & n: i = i + 1
objSongListiterator.Next
n = n + 1
Wend
Set objSongListiterator = Nothing

I was able to retrieve the requested information, but the macro needs to search the whole database.
There must be a better way – please help.
Post Reply