Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / September 2003



Tip: Looking for answers? Try searching our database.

Schema for a Text File - ADO/VB6

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nalaka Hendawitharana - 25 Sep 2003 08:16 GMT
Hi,

I'm new to VB, trying to Import data in text file in to an access
database using a "schema.ini". But my text file has two types of rows
(please refer attached zip file - zipped text file). First row is a
summary of the all other text rows which has less number of columns than
the other rows.

How do I create a schema.ini file ?

Thanks & regards,
Nalaka.

*****************************************

Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim fld As ADODB.Field

cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
         "Data Source=" & "E:\My Documents\TextFiles;" & _
           "Extended Properties=""Text;HDR=NO;FMT=Delimited"""

rs.Open "SELECT * FROM Sample.txt", cnn, adOpenStatic, adLockPessimistic

While Not rs.EOF
   For Each fld In rs.Fields
       Debug.Print fld.Value
   Next fld
   rs.MoveNext
Wend

rs.Close
Set rs = Nothing

cnn.Close
Set cnn = Nothing
Val Mazur - 26 Sep 2003 03:40 GMT
Hi,

You cannot specify different types of columns for different rows. What you
could do in some cases is define type for the actual rows (not the first
one) and then read all the data into recordset. In case if all the fields
defined as character, your first row will be in a recordset as well. Then
delete it from that recordset
Signature

Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp

> Hi,
>
[quoted text clipped - 33 lines]
> cnn.Close
> Set cnn = Nothing
Nalaka Hendawitharana - 27 Sep 2003 06:53 GMT
Hi! Mazur,

Using the following code I extract the other details of my text file from the
record set. But I need to get the first row as well as it contain some
important information.

While Not rs.EOF
   iCount=iCount+1
   if iCount>1 then
       For Each fld In rs.Fields
           Debug.Print fld.Value
        Next fld
    rs.MoveNext
   End If
Wend

Can I read only the First line using the following code

Open MyFile For Binary Input as #1
   '
   '
Close #1

Thanks & Regards,
Nalaka.

P.S: The text file I'm trying to import contains about 25 to 30 thousand
records in total.

> Hi,
>
[quoted text clipped - 46 lines]
> > cnn.Close
> > Set cnn = Nothing
Val Mazur - 30 Sep 2003 03:15 GMT
Hi,

What you could do is to FileSytemObject CO library to read first line of the
file. That library accessible from Microsoft Scripting Runtime and allows to
work with files. It is simple and has set of convenient methods to work with
those files. Here is a KB with example how to use FileSystemObject library

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/s
upport/kb/articles/Q186/1/18.ASP&NoWebContent=1


Signature

Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp

> Hi! Mazur,
>
[quoted text clipped - 75 lines]
> > > cnn.Close
> > > Set cnn = Nothing
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.