Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help optimizing code
Message
From
27/05/2004 13:33:05
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
27/05/2004 09:24:32
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00907685
Message ID:
00907866
Views:
17
Paul,

You can open a fixed-field text file using the Jet ODBC driver. Once you do that, you can create the DataSet on the fly with DataAdapter.FillSchema.

I can post a sample for you tonight.

>Hi all,
>
>As you will notice in the code below I am using the VFP toolkit for .net. Perhaps there are some thing's I could use native vb code that would perform better?
>
>Anyway's what I have is a fixed length ascii file and and ascii "map" file.
>I load the Map file into an array.
>
>lalaselected(i, 0) = lcfieldname
>lalaselected(i, 1) = lclength
>lalaselected(i, 2) = lcstartpos
>lalaselected(i, 3) = lcendpos
>lalaselected(i, 4) = lcdatatype
>
>Then I pass the array to the below function's to create a dataset.The code works perfectly fine but if I could make it any faster that would be great!! Currently my test data file has 50 fields and 2200 records and it takes a bit to run.
>
>Anyway's thanks in advance :-)
>
>
>
> Public Function fillds(ByRef laselected As Array)
>
> Dim DS As DataSet = CreateDataSet(laselected)
> Dim z As Integer
> Dim i As Integer
> Dim ladat As Array
> ALines(ladat, FileToStr("d:\aaaaregq\catitcompletes(UNCLEANED).dat")) 'This will be a param **--FIX--**
>
> For z = 0 To ALen(ladat, 1) - 1
> Dim dataRow As DataRow = DS.Tables("DAT").NewRow
> For i = 0 To ALen(laselected, 1) - 1
> dataRow(laselected(i, 0)) = SubStr(ladat(z), laselected(i, 2), laselected(i, 1))
> Next
> DS.Tables("DAT").Rows.Add(dataRow) 'Add the Row
> Next
> Return DS
>
>
> End Function
>'-----------------------------------------------------
> Private Function CreateDataSet(ByRef laselected) As DataSet
> Dim ds As DataSet = New DataSet("DSDat")
> ds.Tables.Add(CreateTable(laselected))
> Return ds
> End Function
>'------------------------------------------------
>
> Private Function CreateTable(ByRef laselected) As DataTable
>'Create the Data Table with the Selected Fields
> Dim dat As DataTable = New DataTable("dat")
> Dim i As Integer
> For i = 0 To ALen(laselected, 1) - 1
> dat.Columns.Add(New DataColumn(laselected(i, 0), GetType(String)))
> Next
> Return dat
>End Function
>'--------------------------------------------
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform