I'm fairly new to VB.Net. Anyway our office has a simple application written in VB6 thats produces a recordset from an Access database then writes the resulting recordset to a text file. They want it re-written in .Net. I can get the (DAO) recordset to be created correctly in >net but I can't figure out how to write it to a delimited text file using CommonDialog. Any help would be appreciated.
Thanks in advance.
ronhvb03
2 4215
Hi,
Try this function, -
Function Text_To_Datasetst(ByVal filePath As String) As DataSet
-
Dim reader As StreamReader = New StreamReader(filePath)
-
reader.BaseStream.Seek(0, SeekOrigin.Begin)
-
Dim ds As DataSet = New DataSet
-
Dim dt As DataTable = New DataTable
-
ds.Tables.Add("SampleTable")
-
While reader.Peek > -1
-
Dim cnt As Integer = 0
-
drow = dt.NewRow
-
For Each strfields As String In reader.ReadLine.Split(delimiter)
-
drow(cnt) = Convert.ToDouble(strfields.Trim)
-
System.Math.Min(System.Threading.Interlocked.Increment(cnt),cnt-1)
-
Next
-
dt.Rows.Add(drow)
-
End While
-
Return ds
-
End Function
-
Not sure but I think this code writes to a dataset or database. I'm trying to write a DAO recordset to a text file. In the VB 6 app it is laid out like this: -
If RsRpt.RecordCount > 0 Then
-
CommonDialog1.Action = 2
-
strPath = CommonDialog1.FileName + ".txt"
-
' MsgBox "Path = " & strPath
-
If OpList.Value = True Then
-
Open strPath For Output As #1
-
' Open strPath + "\" + strOutFile For Output As #1
-
OpenRecordsetOutput RsRpt
-
Message = "File " + strPath + " has " + Str(RsRpt.RecordCount) + " records"
-
MsgBox Message, vbOKOnly, "File Output info"
-
End If
-
-
-
Sub OpenRecordsetOutput(rstOutput As Recordset)
-
With rstOutput
-
' MsgBox "Writing list file now"
-
Print #1, "YEAR", "|"; "GSE", "|"; "MSA", "|"; "MSA NAME", "|"; "STATE CODE", "|"; "STATE NAME", "|"; _
-
"COUNTY CODE", "|"; "COUNTY NAME", "|"; _
-
"TRACT", "|"; "TRACT PCT RATIO", "|"; "MINORITY PCT", "|"; _
-
"SERVE IND", "|"; "BUYER TYPE", "|"; "ETHNIC GRP", "|"; _
-
"GENDER", "|"; "BO RATIO", "|"; "# OF LOANS"
-
Do While Not .EOF
-
-
Print #1, .Fields(0), "|"; .Fields(1), "|"; .Fields(2), "|"; .Fields(3), "|"; _
-
.Fields(4), "|"; .Fields(5), "|"; .Fields(6), "|"; .Fields(7), "|"; _
-
.Fields(8), "|"; .Fields(9), "|"; .Fields(10), "|"; .Fields(11), "|"; _
-
.Fields(12), "|"; .Fields(13), "|"; .Fields(14), "|"; .Fields(15), "|"; .Fields(16)
-
-
.MoveNext
-
Loop
-
End With
-
'MsgBox "File complete"
-
End Sub
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: va |
last post by:
I am trying to create recordset from a text file. The
text file contains header and records. The text file is
tab delimited. I am using the following statement to
create the recordset
Call...
|
by: Roland Hall |
last post by:
I have two(2) issues.
I'm experiencing a little difficulty and having to resort to a work around.
I already found one bug, although stated the bug was only in ODBC, which I'm
not using. It...
|
by: Roland Hall |
last post by:
I have two(2) issues.
I'm experiencing a little difficulty and having to resort to a work around.
I already found one bug, although stated the bug was only in ODBC, which I'm
not using. It...
|
by: Paul |
last post by:
I was wondering if anyone has had an issue where using vba code to
read an excel file and import the data into an access table some
records are not imported from the excel file. It seems looking at...
|
by: Wendy |
last post by:
Hi
I'm trying to import the contents of a text file which is basically letters
in to a table to add more data to them. The original file comes from the
mainframe.
I'm tring to copy the...
|
by: Billy |
last post by:
Hi All,
I'm attempting to use the MapNetworkDrive <snippedbelow from entire
code below with very poor performance results.
Basically, I have very small 73kb text files that are rewritten daily...
|
by: tdr |
last post by:
I need to compare table 1 to table 2 and if the row/recordset in
table 1 is different from table 2, write the entire row/recordset
from table 1 to table 3.
I can read an entire row/recordset ...
|
by: anniefs |
last post by:
hi
help me i m so much stuck int he code and i have no time ....
i used ASP VBscipt and javascript functions with MS database
javascript function add records in MS DB by using ASP vbscript...
|
by: wallconor |
last post by:
Hi,
I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |