944,155 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Jul 20th, 2007
0

reading records from a .dbf file

Expand Post »
anyone who can help me regarding how to read data from .dbf files recordwise.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
suneel kar is offline Offline
71 posts
since Jul 2007
Jul 20th, 2007
0

Re: reading records from a .dbf file

Click to Expand / Collapse  Quote originally posted by suneel kar ...
anyone who can help me regarding how to read data from .dbf files recordwise.
See it in the thread Access to any type of DB's possible for your dbase and opening 2 files for your writng records to text files


regards
AV Manoharan
Last edited by AV Manoharan; Jul 20th, 2007 at 7:17 am.
Reputation Points: 10
Solved Threads: 9
Junior Poster
AV Manoharan is offline Offline
166 posts
since Jun 2007
Jul 21st, 2007
0

Re: reading records from a .dbf file

Hi Suneel,

Add DAO reference :Microsoft DAO 3.51 object Library To ur Project and use thos code:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim DB As Datbase
  2. Dim RST As RecordSet
  3. Dim sSQL As String
  4. Set DB = DBEngine.OpenDatabase("C:\MyDBFFolder", False, False, "dBASE III;")
  5. sSQL= "Select * From MyTable"
  6. Set RST= DB.penRecordset(sSQL)

Note In Above DB Statement, u have to specify the path of Folder Name where Dbf files are Located. and u can change the
DBase III according to ur dbase version.

REgards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Jul 21st, 2007
0

Re: reading records from a .dbf file

hi veena ,
thanx for replyin. will u plz tell me what actually this statement does in code.
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\Resources\MNYL.mdb ; Persist Security Info=False"

As i am new to programming in visual basics so tell me any way to get every cocept clear.
any book if u recomend me .will be thankful.
dabasish and u have strong knowlge of vb .keep it up .
regards
suneel kar









Click to Expand / Collapse  Quote originally posted by QVeen72 ...
Hi Suneel,

Add DAO reference :Microsoft DAO 3.51 object Library To ur Project and use thos code:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim DB As Datbase
  2. Dim RST As RecordSet
  3. Dim sSQL As String
  4. Set DB = DBEngine.OpenDatabase("C:\MyDBFFolder", False, False, "dBASE III;")
  5. sSQL= "Select * From MyTable"
  6. Set RST= DB.penRecordset(sSQL)

Note In Above DB Statement, u have to specify the path of Folder Name where Dbf files are Located. and u can change the
DBase III according to ur dbase version.

REgards
Veena
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
suneel kar is offline Offline
71 posts
since Jul 2007
Jul 21st, 2007
0

Re: reading records from a .dbf file

hi veeva
i am gettin confused dear. as per debashish he is sayin ADO is advanced one which we r using now and u sayin DAO
sort out the things and reply which to use
regards
suneel kar




Click to Expand / Collapse  Quote originally posted by suneel kar ...
hi veena ,
thanx for replyin. will u plz tell me what actually this statement does in code.
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\Resources\MNYL.mdb ; Persist Security Info=False"

As i am new to programming in visual basics so tell me any way to get every cocept clear.
any book if u recomend me .will be thankful.
dabasish and u have strong knowlge of vb .keep it up .
regards
suneel kar
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
suneel kar is offline Offline
71 posts
since Jul 2007
Jul 22nd, 2007
0

Re: reading records from a .dbf file

Hi vee!
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Set db = OpenDatabase(App.Path & "\COLOR.dbf", False, False, "dBase IV;")
I try your code because I also use some dBase but it has an error "C:\report\Color.dbf" isn't a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.I don't understand why because the color.dbf file is in the folder c:\report and my VB Project is also on that folder too. Why it makes an error like that?
Last edited by jireh; Jul 22nd, 2007 at 8:54 pm.
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007
Jul 23rd, 2007
0

Re: reading records from a .dbf file

Hi Jireh,

Look as i said in my post u should mention only dbf's "Path"
change "C:\report\Color.dbf" this to
"C:\report"


DBF files donot have the concept of Single Databeas, each tables are stored as seperate
files, thats the reason we need to mention Folder path of dbf files.

Hi Suneel,
DBF is a older technology of databases. It may be possible to open dbf with ADO also, but I think they can be accessed fast using DAO's .

Regards
Veena
Last edited by QVeen72; Jul 23rd, 2007 at 3:43 am.
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Jul 23rd, 2007
0

Re: reading records from a .dbf file

hello debashish,veena
have alook n the code.when i am compiling this it is givin me unknown databse format.
regards
suneel


Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\CHECK_2045.dbf ; Persist Security Info=False"
rs.Open Text1.Text, con, adOpenForwardOnly, adLockOptimistic
Dim str As String
If Dir("c:\Suneel_Development\New Folder\record reading\data.txt") <> "" Then
Kill "c:\Suneel_Development\New Folder\data.txt"
End If
Open "c:\Suneel_Development\New Folder\DATA.TXT" For Append As #1
Do While rs.EOF = False
For i = 0 To rs.Fields.Count - 1
If i < rs.Fields.Count - 1 Then
str = str & IIf(IsNull(rs(i)), "null", rs(i)) & Chr(9)
Else
str = str & IIf(IsNull(rs(i)), "null", rs(i))
End If
Next
Print #1, str
rs.MoveNext
str = ""
Loop
Close #1
rs.Close
con.Close
End Sub








Click to Expand / Collapse  Quote originally posted by QVeen72 ...
Hi Jireh,

Look as i said in my post u should mention only dbf's "Path"
change "C:\report\Color.dbf" this to
"C:\report"


DBF files donot have the concept of Single Databeas, each tables are stored as seperate
files, thats the reason we need to mention Folder path of dbf files.

Hi Suneel,
DBF is a older technology of databases. It may be possible to open dbf with ADO also, but I think they can be accessed fast using DAO's .

Regards
Veena
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
suneel kar is offline Offline
71 posts
since Jul 2007
Jul 23rd, 2007
0

Re: reading records from a .dbf file

Hi Suneel,

if u r using ADO, then open Connection like this:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & ";Extended Properties=DBase IV"

u have to give Extended properties in connection string, and when it comes to .dbf or older Foxpro Versions of data, they dont have a single DB, u have to mention Folder path name.


Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Jul 23rd, 2007
0

Re: reading records from a .dbf file

Hi Suneel,

What does ur Text1.Text contain...?
It shoud have either Table name (CHECK_2045) or a Select Query Statment (Select * From CHECK_2045)


Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Datepicker Control
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Linking two or more list boxes





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC