Question Problem with saving a filename into an Access database.

Rip_Uk

Member
Joined
Jun 7, 2008
Messages
5
Programming Experience
Beginner
Hello,

This is my first post, I have found this forum using Google, maybe someone can help me with my question as I cannot find an answer through google.

I would like to save a filename to an Access database using an Open File Dialog. The program I am building is an Mp3 player. The way it works is when a user clicks the load button the open file dialog filename is saved into the database and added to the listbox playlist queue from the database.

I have saved a file into the database if that file is stored in the \bin folder but If I need to access a parent directory and save that filename e.g C:\mp3\my tune.mp3 I get an error.

"c:\mp3\system\playlist.mdb is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides."

c:\mp3 is the directory returned from the open file dialog and \system\playlist.mdb is where the database is stored. Why is VB.NET placing these two together and how can I access an .mp3 file that is stored anywhere on the computer and not just the \bin folder..?
 
Have you stepped through the storing process yet? It would also help us to help you if you could post some code.
 
The code that you have that puts the data into the database or the code that gets the data ready to put into the database.
 
Of yes of course, the problem line is with the da.Update obviously but the error I get is something to do with a permission error I believe.

Here is the code to my Open Mp3 button....

VB.NET:
Private Sub pbOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pbOpen.Click
        Try
            ofd.Title = "Load Audio File"
            'add filter
            ofd.Filter = "Mp3 Files (*.mp3)|*.mp3|All files (*.*)|*.*"
            If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
                Dim cb As New OleDb.OleDbCommandBuilder(da)
                Dim dsNewRow As DataRow
                dsNewRow = ds.Tables("Playlist").NewRow
                dsNewRow.Item(0) = ofd.FileName
                ds.Tables("Playlist").Rows.Add(dsNewRow)
                da.Update(ds, "Playlist")
                           End If
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub
 
i dunno about anyone else's interpretation, but your Open MP3 button seems to store the filename of the MP3 in the database.. Personally I'd expect an Open MP3 button, to.. er.. open it?
 
Well, its not the play button... its the load mp3 button, it loads an mp3 into the playlist ready to be played. The reason for this is so a user can load multiple files which are stored in a database for access later. also, if the program is closed and re-opend the contents of the playlist still remain. do you have a better way of storing this data?
 
Back
Top