Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 4th, 2009, 10:15 PM   #1
jinteoh
Newbie
 
Join Date: Feb 2009
Posts: 4
Rep Power: 0 jinteoh is on a distinguished road
How to read the data from .dat and store into access file by using vb?

Dear All,

Do anyone know how to read a record from .dat file and write into access file by using vb?

Thanks.
jinteoh is offline   Reply With Quote
Old Feb 4th, 2009, 10:55 PM   #2
MasterWill
C/C++ Developer
 
MasterWill's Avatar
 
Join Date: Sep 2008
Location: Florida, USA
Posts: 130
Rep Power: 6 MasterWill is on a distinguished road
Exclamation Re: How to read the data from .dat and store into access file by using vb?

Quote:
Originally Posted by jinteoh View Post
Dear All,

Do anyone know how to read a record from .dat file and write into access file by using vb?

Thanks.
This subject was discussed a number of times - try doing a search on the site. Also, reading from a ".dat" file really does not mean anything to anyone. ".dat" is not a particular file type; it can be anything from lines of text to binary data. To get specific help you really need to post a sample of what is in the file.

Assuming that the file contains lines of text that represent the records you want to add to your Access file, take a look at the Open, Line Input, and Close statements if you are using VB6. If you are using VB.NET, take a look at the System.IO.FileStream class. A Google search will turn up plenty of examples, I would imagine.

As to adding the records to the database, there are a number of ways to do it. For VB6, Google for examples of DAO or ADO, depending on your preference. For VB.NET, Google for ADO.NET, System.Data.OleDbConnection, System.Data.OleDbDataAdapter, and such. The MSDN website is also very useful since you are working with VB and Access.

Just as an aside, please note that most of the members here are not going to do your homework for you, especially if you do not show any attempt on your part (i.e. doing some research with Google, writing some code, etc). We are here as a support group for those who try to work things out for themselves but are stuck on a problem that they cannot figure out; we are not here to provide code on a silver platter to all who ask for it.

That being said, try looking up the items I suggested - you will probably be able to solve it for yourself using the numerous examples that are widely available. If you have been able to put together the application and are still having problems, post your code and one or more of the members here will help you out - please remember to use CODE tags to wrap the code you post.
__________________
-- William
MasterWill is offline   Reply With Quote
Old Feb 5th, 2009, 2:52 AM   #3
jinteoh
Newbie
 
Join Date: Feb 2009
Posts: 4
Rep Power: 0 jinteoh is on a distinguished road
Re: How to read the data from .dat and store into access file by using vb?

Hi William,

Thanks for your advise.

Actually I am doing a project for my company. The project is to create reports by using our existing database from a accounting software. The software is develop by using Delphi and the data are store in .dat file (I think it is a binary file). I try to using Crystal Report to connect to the file but cannot. So I just thinking about maybe I have to find a way to convert the data from .dat into Access file. Here I attached together with sample file.

Regards,
Jin
Attached Files
File Type: zip sample.zip (10.8 KB, 139 views)
jinteoh is offline   Reply With Quote
Old Feb 5th, 2009, 7:10 PM   #4
MasterWill
C/C++ Developer
 
MasterWill's Avatar
 
Join Date: Sep 2008
Location: Florida, USA
Posts: 130
Rep Power: 6 MasterWill is on a distinguished road
Talking Re: How to read the data from .dat and store into access file by using vb?

Sorry if I came across a little short before; made the assumption it was a homework project.

It is a binary file, but not one that I can read. My first thought was a DBase or Paradox file, but the header does not appear to match either. Could be something proprietary. I wish I knew what else to suggest other than try to change the file extension to ".dbf" or ".db" and try to link the file into an Access database as either DBase or Paradox, respectively. If that works, you can access the table like you would any other table in the database.

HTH
__________________
-- William
MasterWill is offline   Reply With Quote
Old Feb 5th, 2009, 7:43 PM   #5
jinteoh
Newbie
 
Join Date: Feb 2009
Posts: 4
Rep Power: 0 jinteoh is on a distinguished road
Re: How to read the data from .dat and store into access file by using vb?

Dear William,

Thanks for your suggestion, I will try it and let you know the result.

Regards,
Jin
jinteoh is offline   Reply With Quote
Old Feb 5th, 2009, 8:50 PM   #6
jinteoh
Newbie
 
Join Date: Feb 2009
Posts: 4
Rep Power: 0 jinteoh is on a distinguished road
Re: How to read the data from .dat and store into access file by using vb?

Hi William,

Sorry to tell you that it dose not working. The error message " Not a expected format".

Anyway, I will find a way out and i will let you know when I get it. Thanks a lot.

Jin
jinteoh is offline   Reply With Quote
Old Feb 27th, 2009, 12:46 PM   #7
exception
Critical Programmer
 
exception's Avatar
 
Join Date: Oct 2008
Location: Philippines
Posts: 172
Rep Power: 6 exception is on a distinguished road
Send a message via Yahoo to exception
Re: How to read the data from .dat and store into access file by using vb?

You can use

Open app.path & "\[Filename]" for Input As #1 'use this if you want to retrieve the data
then use Input #1 ,[var],[var],[var],[var] ' variables which holds the data

Open app.path & "\[Filename]" for Output As #1 'use this if you want to create new the file
Output #1,[var],[var],[var],[var] 'but this will overwrite if the file already exist use append if you just want to add data

Open app.path & "\[Filename]" for Append As #1 'use this if you want to append the data
Append #1 [var],[var],[var],[var]

that's all folks
__________________
|Knowledge alone is not POWER, Applied knowledge is POWER.
exception is offline   Reply With Quote
Old May 9th, 2009, 1:41 AM   #8
eswari
Newbie
 
Join Date: May 2009
Posts: 1
Rep Power: 0 eswari is on a distinguished road
Re: How to read the data from .dat and store into access file by using vb?

Quote:
Originally Posted by jinteoh View Post
Dear All,

Do anyone know how to read a record from .dat file and write into access file by using vb?

Thanks.
do u have any sample example for to read a record from .dat file in excel worksheet
eswari is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
read from a file and printf & store in a array subhobrata C 1 Dec 15th, 2008 3:57 PM
How to store 5 numbers from a file into 5 seperate variables? kewlgeye Java 8 Jun 26th, 2008 2:09 PM
VB Project (Grocery Store) redfiretruck Visual Basic .NET 4 Apr 20th, 2008 4:45 AM
How to store XML data in ACCESS DB using VB6 kartik07 Visual Basic 1 Jan 1st, 2008 12:35 PM
How to read a line of from a file aznluvsmc C 12 Oct 22nd, 2005 5:36 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC