Solved

loop through access table rows vb.net

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

627 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