Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Importing text file to Access Database

Reply
 
Old 09-19-2008   #1 (permalink)
Codeblack


 
 

Importing text file to Access Database

Hi,

Does any one know how to import a delimeted text file into access database
using VBscript. Any suggestions is appreciated.

Thanks

My System SpecsSystem Spec
Old 09-19-2008   #2 (permalink)
Codeblack


 
 

RE: Importing text file to Access Database

The data is something like this.

abc.rtd@xxxxxx,unknown,google.com,290447512478,714
My System SpecsSystem Spec
Old 09-20-2008   #3 (permalink)
hb21l6


 
 

Re: Importing text file to Access Database


"Codeblack" <Codeblack@xxxxxx> wrote in message
news:F68F65F2-4FEE-4015-BEE5-EE89EFFF074A@xxxxxx
Quote:

> The data is something like this.
>
> abc.rtd@xxxxxx,unknown,google.com,290447512478,714
>
that depends on how much in depth you want to go with it,

Firstly, you need to read the txt file..

myFile = "C:\mytextFile"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(myFile,1)

If objFSO.FileExists(HFiles) Then
' see if the file exists and open it
Set HFile = objFSO.OpenTextFile(myFile,8, True)
else
' Create a Header file
Set HFile = objFSO.CreateTextFile(myFile, True)
End If


THIS IS HOW YOU MAKE A CONNECTION TO A msACCESS DATABASE

Set dbConn= Server.CreateObject("ADODB.Connection")
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\db2.mdb;Persist Security Info=False"
dbConn.Open(sConnString)
SET rsupdate = server.createObject("adodb.recordset")

Do Until objFile.AtEndOfLine
' here is your line of data.
line=objFile.ReadLine
' you now need to split this line using the Split() object to parse out each
field from the line


SQL = "insert into tbl_name (field1, field2 field3, etc) values ('" & val1 &
"', " & val2 & ", '" & val3 & "')"

SET rsupdate = dbconn.execute(SQL)


Loop

set rsupdate = nothing
set dbconn = nothing



YOU WILL NEED TO ALTER THIS TO SUITE YOUR NEEDS.



Dave



My System SpecsSystem Spec
Old 09-20-2008   #4 (permalink)
Codeblack


 
 

Re: Importing text file to Access Database

Thanks Dave. Will try this out. Thanks for your suggestion.

Regards
Codeblack
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
importing text VB Script
Export Microsoft Access Database to Text File .NET General
Convert hostname text file to IP text file VB Script
Database access... VB Script
comma delimited text file into database PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46