Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 11th, 2008, 04:34 PM
Registered User
 
Join Date: Jul 2006
Location: hyderabad, andhra pradesh, India.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sparsh2010
Default Read file and store it to database

Hi,

     I am trying to read file (C:\Test.txt) and read it line by line and store the values into a MS access database table name TEMP
ERROR : Run Time Error 3134
TEMP
Field = EMPLOYEE (Primary Key)

i have tried following code

Dim sFileText, strPictureFilename As String
Dim iFileNo As Integer

Open "C:\Test.txt" For Input As #iFileNo

Do While Not EOF(iFileNo)
        Input #iFileNo, sFileText
        strPictureFilename = sFileText

         SQL = "Insert Into TEST EMPLOYEE Values '" & strPictureFilename & "'"

        DoCmd.RunSQL SQL
Loop

  Close #iFileNo


Pramod Chandra
Reply With Quote
  #2 (permalink)  
Old July 14th, 2008, 06:53 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Can you post some sample data from the text file, and the table structure from the table? This is a pretty easy process. I use Scripting.FileSystemObjects, however.

It also looks like you are having issues with the EMPLOYEE field being the PK field and duplicate values trying to be inserted. Is that that problem?

Please post more information and I will post some tested code.

mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote
  #3 (permalink)  
Old July 14th, 2008, 03:31 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Your SQL is wrong.

The format of INSERT is
    INSERT INTO <tablename> ( <list of fields> ) VALUES( <list of values > )

The parentheses are *NOT* optional!

So:

SQL = "Insert Into TEST ( EMPLOYEE ) Values ('" & strPictureFilename & "')"
Reply With Quote
  #4 (permalink)  
Old July 17th, 2008, 08:27 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Did this work for you?

mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read excel file into database wk ASP.NET 2.0 Basics 7 June 12th, 2007 06:53 AM
How to store MS Word File in database kesar SQL Language 2 March 1st, 2007 06:34 AM
DTS Package, XML task. Read XML file and store it Victoria SQL Server DTS 0 July 24th, 2006 02:43 PM
how to store file in sql server 2000 database vivekkumar_23 SQL Server 2000 1 February 27th, 2006 10:41 PM
how to store text file in database vivekkumar_23 Servlets 1 February 13th, 2006 05:29 AM



All times are GMT -4. The time now is 08:23 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.