Solved

loop through access table rows vb.net

Posted on 2012-03-19
2
295 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now