Solved

loop through access table rows vb.net

Posted on 2012-03-19
2
306 Views
Last Modified: 2012-03-28
Hi guys

 I have a table in a access db it has several fields, but i am only interested in 2.

the first field is uniquekey, this represents the db uniquekey of each track
ie: 3402
     5601
     6507


the second field is filename

which is basically the full path to where the track is stored,
i.e. Filename  D:\Tracks\fff250bd-6c12-4f11-ab9e-a84568a74afb\1cd6e11e-b89e-4899-9aea-31f01401b18c.mp3

I need to copy and rename the files to another folder from all the rows in the table renaming the mp3 files to the uniquekey.

the database name is library
the table is csv

 Could anybody please give me some code to achieve this in vb.net

Best regards

Jimbo
0
Comment
Question by:Jimbo1954
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37739136
Fetched from
http://msdn.microsoft.com/en-us/library/dw70f090%28v=vs.80%29.aspx
and
http://msdn.microsoft.com/en-us/library/aa302325.aspx
here is the sample code, please make the necessary changes as and where required:-
    'Set up connection string
    Dim cnString As String
     
    cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=..\data\Northwind.mdb"
     
    'create command (with both text and connection), change your query accordingly
    Dim sqlQRY As String = "SELECT * FROM tracks"
     
    'Create connection
    Dim conn As OleDbConnection = New OleDbConnection(cnString)
     
    Try
    ' Open connection
    conn.Open()
     
    Dim cmd As OleDbCommand = New OleDbCommand(sqlQRY, conn)
     
    'create data reader
    Dim rdr As OleDbDataReader = cmd.ExecuteReader
     
    While (rdr.Read)
    Dim strTrack as string = rdr("TrackPath").ToString()
    'write this method as per your needs and process the tracks
    ProcessTrack(strTrack);
    End While
     
    Catch ex As SqlException

    Finally
    ' Close connection
    conn.Close()

    End Try

Open in new window

0
 

Author Closing Comment

by:Jimbo1954
ID: 37778459
Thankyou, <br /><br />Jimbo
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question