|
-
Jun 6th, 2003, 07:48 AM
#1
Thread Starter
Junior Member
Urgent help - saving data as a text file
Please can anyone help?
I have a small access database that the user can update via my vb application (add/delete/print etc.)
I want to add a button that when clicked will save all the data as well as a few fixed characters that need to be added ie. "F13" at the beginning of each row into a text file called extel.dat.
The reason for this is the datadase holds details of price changes for our accounting system which we can import.
If the fields are - Sedol= 0012342, Bid=23.45, Offer=30.11 I need the line in the text file to be:-
F13001234200023450003011
Is this possible?
I've attached some current code below
Many thanks
Mark.
Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to FillDataSet.
'A temporary dataset is used because filling the existing dataset would
'require the databindings to be rebound.
Dim objDataSetTemp As Impart_Price_DBMH.JoveDB
objDataSetTemp = New Impart_Price_DBMH.JoveDB()
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objJoveDB.Clear()
'Merge the records into the main dataset.
objJoveDB.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try
End Sub
Public Sub UpdateDataSource(ByVal ChangedRows As Impart_Price_DBMH.JoveDB)
Try
'The data source only needs to be updated if there are changes pending.
If (Not (ChangedRows) Is Nothing) Then
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to update the data source.
OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
'Add your error handling code here.
Throw updateException
Finally
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As Impart_Price_DBMH.JoveDB)
'Turn off constraint checking before the dataset is filled.
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException
Finally
'Turn constraint checking back on.
dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|