Importing excel file to database

I have one Excel csv format file consists of custermer address info.
I want to import this file to Ms access database by taking the header as datafield by using VB.Net 2005. please help me to solve this problem.
G.Manivannan, M.Sc.,[it],
VBA Programmer,
AKUVA Infotech, Bangalore.


  • seancampbellseancampbell Pennsylvania, USA
    This function will load your CSV file into memory
    All you need to do is write the code to get it into your DB

    Private Sub LoadEXCELinMemory()

    'This will set FF = 1 in most cases
    Dim FF As Integer = FreeFile()
    'To break each line into first
    Dim S() As String
    'Create a String Array to split each line of
    'the config file into
    Dim Str(,) As String
    'Create a temp String to grab the full line into
    Dim TempStr As String
    'Create an integer to keep track of what rows
    'While ReDimming Str(,)
    Dim i As Integer = 0
    'Define the applications path
    Dim AppPath As String = Application.StartupPath
    If AppPath.Substring(AppPath.Length - 1) <> "" Then AppPath &= ""

    'Open File with FF as the reference number
    'Can change the filepath to whatever you need
    FileOpen(FF, AppPath & "test.csv", OpenMode.Input)

    Do While Not EOF(FF)

    Input(FF, TempStr)

    S = TempStr.Split(",")

    ReDim Preserve Str(i, S.Length)

    For h As Integer = 0 To S.Length
    Str(i, h) = S(h)

    i += 1



    'now Everything that was in your CSV file is in memory in the STR object
    'If you Dim STR in a Module (making it Global) you can
    'write a new function that then puts that information into a Database
    'Hope this helps

    End Sub
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion