Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

loop through access table rows vb.net

Posted on 2012-03-19
2
Medium Priority
?
309 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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

688 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