473,569 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Text into Access

Art
I've already posted a number of questions on this topic and everyone has been extremely helpful. I've yet another (related) question.

I want to bring a text file into an Access table using vb.net. With your help I've been able to do this. The problem I'm now running into is that the first row of the text file becomes my field names. Is there any way to specify the field names in the SQL -- when putting the data into a new table? Or... if inserting the data into an existing table do I need to have field names in the text file?

Art
Nov 20 '05 #1
4 1650
On Tue, 13 Jul 2004 05:17:03 -0700, Art <Ar*@discussion s.microsoft.com > wrote:

¤ I've already posted a number of questions on this topic and everyone has been extremely helpful. I've yet another (related) question.
¤
¤ I want to bring a text file into an Access table using vb.net. With your help I've been able to do this. The problem I'm now running into is that the first row of the text file becomes my field names.

You have to include HDR=No in your connection string to the text file:

[Text;DATABASE=D :\My Documents\TextF iles;HDR=No].[Table1.txt]

¤ Is there any way to specify the field names in the SQL -- when putting the data into a new table? Or... if inserting the data into an existing table do I need to have field names in the text file?

You can define your own in a schema.ini file:

http://msdn.microsoft.com/library/de...a_ini_file.asp

If you don't use a schema.ini file the column names default to F1, F2, F3, etc.

If you are inserting into an existing table I believe that the column names from the source and
destination table must match in order to omit the column names from the SQL statement.
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #2
Art
Paul,

Thanks very much for your help -- it's just what I needed.

Art
Nov 20 '05 #3
Art
Paul,

I think I could use a hint about the schemas you've pointed me to. Could tell how (or where to look) to direct my vb.net progam to use the schema once I've set it up? Also, I've looked at the reference on schemas, and I probably will be able to create one that I need -- but if you know of an example of one it will definitely save me a lot of trial and error with regard to writing a syntactically correct definition.

Thanks again for you help - even if you don't have time to help with this second request.

Art
Nov 20 '05 #4
On Thu, 15 Jul 2004 05:14:14 -0700, Art <Ar*@discussion s.microsoft.com > wrote:

¤ Paul,
¤
¤ I think I could use a hint about the schemas you've pointed me to. Could tell how (or where to look) to direct my vb.net progam to use the schema once I've set it up?
¤ Also, I've looked at the reference on schemas, and I probably will be able to create one that I need -- but if you know of an example of one it will definitely save me a
¤ lot of trial and error with regard to writing a syntactically correct definition.
¤
¤ Thanks again for you help - even if you don't have time to help with this second request.

The schema.ini file should be placed in the same folder as the text files. That is where the driver
will look.

Here are a few examples of entries in a schema.ini file:

[FixLength.txt]
ColNameHeader=F alse
CharacterSet=AN SI
Format=FixedLen gth
Col1=ColName1 Text Width 3
Col2=ColName2 Text Width 15
Col3=ColName3 Text Width 15
Col4=ColName4 Text Width 11
Col5=ColName5 Text Width 1
Col6=ColName6 Text Width 1
Col7=ColName7 Text Width 89

[Test.csv]
ColNameHeader=F alse
CharacterSet=AN SI
Format=CSVDelim ited
Col1=F1 Integer
Col2=F2 Integer
Col3=F3 Integer
Col4=F4 Integer
Col5=F5 Char Width 255
Col6=F6 Char Width 255
Col7=F7 Integer
Col8=F8 Integer
Col9=F9 Integer
Col10=F10 Char Width 255
Col11=F11 Integer
Col12=F12 Char Width 255
Col13=F13 Char Width 255
Col14=F14 Integer
Col15=F15 Integer

[Output.txt]
ColNameHeader=F alse
CharacterSet=AN SI
Format=CSVDelim ited
DateTimeFormat= "yyyy-mm-dd hh:nn:ss"

Col1=TRACKING_N UMBER Char
Col2=TELEPHONE_ NUMBER Char
Col3=FIRSTNAME Char
Col4=LASTNAME Char
Col5=ADDRESS1 Char
Col6=ADDRESS2 Char
Col7=CITY Char
Col8=STATE Char
Col9=ZIP Char
Col10=LANGUAGE Char
Col11=DATE_OF_R EQUEST Date
Col12=FILLER1 Char
Col13=QUESTION Memo
Col14=IMPORT_FI LENAME Char
Col15=IMPORTDAT E Date
Col16=STATUSCOD E Char
Col17=STATUS_DE SCRIPTION Char
Col18=OPENDATE Date
Col19=ASPEN_DAT E Date
Col20=ANSWER Memo
Col21=USERID Char
Col22=DATE_ASSI GNED Date
Col23=UPDATES Memo
Col24=SAIC_EXPO RTDATE Date
Col25=PRIORITY_ LEVEL Char
Col26=TOPIC_ID Char
Col27=DISPOSITI ON_CODE Char
Col28=SAIC_EXPO RTNAME Char
Col29=ASPEN_EXP ORTNAME Char
Col30=ASPEN_EXP ORTDATE Date
Col31=REVISED_Q UESTION Memo
Col32=COMMENTS Memo
Col33=ANSWER_RE SOURCE Char
Col34=ANSWER_RE SOURCE_DETAIL Char
Col35=CALL_COUN T Char
Col36=REF_ACTIV ITY_NAME Char
Col37=CATEGORY Char
Col38=CALLBACK Char
Col39=LOCATION Char
Col40=PRIORITY_ REASON Char
Col41=NOT_REF_C TR Char
Col42=EXCEPTION _TO_48_HR Char

[Sample.txt]
ColNameHeader=F alse
CharacterSet=AN SI
Format=Delimite d(|)
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4247
by: NewBob | last post by:
Since Access automatically highlights all of the text in a text control (I use it to hold data from a memo field) when the control is activated, I've added the following code to put the cursor at the end. Private Sub txtCapability_GotFocus() ‘ Placed either behind the OnEnter or GotFocus Event of a control named, ' in this case,...
4
6139
by: Neil | last post by:
I just noticed that control tips aren't working in any of my databases. I recently installed Access 2003, and created a database in it, and noticed that control tips weren't working in my controls. I was using control tips with command buttons in the form header. But they also didn't work with the command buttons in the detail section, nor...
3
4550
by: vtashore | last post by:
I downloaded Steve Leban's RTF2 control and it works as advertised. Good news! After reading reference material on the RTF standard codes, I have been able to write update queries to universally change the font or font size directly in my table without having to edit the text natively in Leban's control. Also good news. I see that there...
9
8275
by: Neil | last post by:
I need to implement a rich text box in an MDB file for a user base that consists of Access 2000 and Access 2002. Unfortunately, I'm using Access 2003 on my development machine. My understanding is that because of security issues, the Microsoft Rich Textbox Control doesn't work in Access 2003. Thus, I'm left with 3 options: 1) Downgrade my...
7
2606
prn
by: prn | last post by:
Hi folks, Sometime in the last few days, I must have accidentally done something that changed some kind of switch in Access, but I can't seem to find what it was. This is Access 2003 under XP, BTW. Currently, when I'm editing any kind of textual material within Access, e.g. a SQL statement or something in the Properties for a GUI element,...
4
5453
by: Neil | last post by:
Just found out that the Microsoft Rich Textbox does not support full text justification, since it's based on Version 1.0 of the RichEdit Window Class, and full text justification is only available in versions 3.0 or later of the class. However, also just found out that the new Rich Text property in Access 2007 ALSO does not support full...
16
11050
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might know one way or the other whether that was true or not, or could point me to an article or help text that would. What I have seen so far online and in...
0
13521
Dököll
by: Dököll | last post by:
Continued from: http://www.thescripts.com/forum/thread762010.html -VB 6.0 Professional -Microsoft DAO 3.6 Reference Search Database table... An attempt to fetch data housed in Access:
16
7171
by: Wayne | last post by:
I've read that one method of repairing a misbehaving database is to save all database objects as text and then rebuild them from the text files. I've used the following code posted by Lyle Fairfield to accomplish the first step: Private Sub SaveObjectsAsText() path = CurrentProject.path & "\ObjectsAsText\" SaveDataAccessPagesAsText...
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.