SDB.Database.Commit

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: SDB.Database.Commit

Re: SDB.Database.Commit

by Peke » Sat Dec 12, 2009 10:41 pm

Are you using Playlist irect in DB Playlist or as SongList?

I would Suggest that you use new created Songlist DIM and when all is Done use AddTracks to Create new Playlist and Add all tracks at once. It will speed up Script and Lower Queries on MM Library.

Example (Not tested but it should be like that):

Code: Select all

DIM LastFavorites
'Case 1
'Set LastFavorites = CreateObject("SongsDB.SDBSongList")

'Case 2
'Set LastFavorites = SDB.NewSongList

Do While Not list.EOF
   Set Add_me = list.item
   LastFavorites.Add(Add_me)
   SDB.ProcessMessages
Loop

Playlist.AddTracks(LastFavorites)
SDB.ProcessMessages

LastFavorites = Nothing
Experiment and see which one is better/faster

SDB.Database.Commit

by Psyker7 » Sat Dec 12, 2009 8:28 pm

For my own education:

I'm wondering why I need to use a SDB.Database.Commit in the following code - If I don't then adding a track to a playlist causes the script to hang.
The only sql being done is a SDB.Database.QuerySongs and the wiki mentions that commit should only be needed if SDB.Database.BeginTransaction is used.

Code sample below:

Code: Select all

Set list = SDB.Database.QuerySongs("Artist = '" & CorrectSt(ArtistName) & "' AND SongTitle = '" & CorrectSt(TrackTitle) & "'")
				SDB.Database.Commit

				If list.EOF Then
					Not_Added = Not_Added & VbCrLf & TrackTitle & " - " & ArtistName
				End If

				Plays = -1
				Num_Dupes = 0

				Do While Not list.EOF

					Num_Dupes = Num_Dupes + 1
					If list.item.Playcounter > Plays Then
						Set Add_me = list.item
						Plays = list.item.Playcounter
						SDB.ProcessMessages
					End If
					list.Next
					
					SDB.ProcessMessages
				Loop

				
				SDB.ProcessMessages

				If Plays >= 0 Then
					
					Playlist.AddTrack(Add_me)
					logme "--Was added"
				Else
					logme "--Was not found in database"
				End If

Top