![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | RE: Importing text file to Access Database The data is something like this. abc.rtd@xxxxxx,unknown,google.com,290447512478,714 |
My System Specs![]() |
| | #3 (permalink) |
| | 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 > 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 Specs![]() |
| | #4 (permalink) |
| | Re: Importing text file to Access Database Thanks Dave. Will try this out. Thanks for your suggestion. Regards Codeblack |
My System Specs![]() |
![]() |
| 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 | |||