SQL select based on file path

Post a reply

Visual Confirmation

To prevent automated access and spam, you are required to confirm that you are human. Please place a check mark next to all images of monkeys or apes. If you cannot see any images, please contact the Board Administrator.

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: SQL select based on file path

Re: SQL select based on file path

Post by highonv8splash » Mon Jul 05, 2010 5:47 am

Thanks for the help guys, got it all sorted out now :)

Re: SQL select based on file path

Post by DazB » Thu Jun 24, 2010 6:47 pm

Hi,

There is the possibility of the same path existing on multiple drives so query for the drive letter also.

Daz

Re: SQL select based on file path

Post by Mizery_Made » Mon Jun 21, 2010 2:42 pm

"SongPath" doesn't contain the drive letter, as that's determined by the "IDMedia" field along with the "Medias" table. So SongPath would = ":\Users\cclub\Music\Real Music\Muzak\Music\AC@_DC\Back In Black\06 Back In Black.mp3"

SQL select based on file path

Post by highonv8splash » Mon Jun 21, 2010 10:30 am

Hi everyone,

I've just gotten the sample VBscripts working and have started working on my own script with the Read and Write sample as my base. I've read through the wiki documentation a fair amount already, I'm hoping someone can point out a stupid mistake that I'm making, it's been a while since I've written in VBscript :) . I want to be able to pull Songs.ID based on the path of the file.

Code: Select all
 'Set file path
 StringFilePath = "C:\Users\cclub\Music\Real Music\Muzak\Music\AC@_DC\Back In Black\06 Back In Black.mp3"

  'Set Data Selection Method
  SelectMethod = 2

'Random SampleID Code (Remove if SampleID known)
  Set iter = SDB.Database.OpenSQL("SELECT DISTINCT Songs.ID FROM Songs WHERE Songs.SongPath = '" & StringFilePath & "'")
 
  While Not iter.EOF
    SampleID = iter.StringByIndex(0)
  iter.Next
  Wend
  StringNewTitle = "Butterflyz"
  Set objSongList = SDB.NewSongList                                                 'SelectMethod 2 and 3 SDB.NewSongList
 
  Select Case SelectMethod
    Case 1
      Set objSongData = SDB.Player.CurrentSong                                      'SDB.Player.CurrentSong
    Case 2
      Set objSongListiterator = SDB.Database.QuerySongs("AND Songs.ID=" & SampleID) 'SDB.Database.QuerySongs


It's failing on the very last line in that code block, but it looks like its failing because it doesn't have a SampleID, so I'm assuming its a result of my first SQL statement not returning anything. I don't understand why this would happen, I've tried using various different forms of the path (%20 instead of spaces, etc). When I put that path into an explorer window, it finds and launches the file just fine.

Any thoughts?

Top