User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 391,913 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,703 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 8776 | Replies: 64 | Solved
Reply
Join Date: Jul 2007
Posts: 71
Reputation: suneel kar is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
suneel kar suneel kar is offline Offline
Junior Poster in Training

reading records from a .dbf file

  #1  
Jul 20th, 2007
anyone who can help me regarding how to read data from .dbf files recordwise.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Posts: 166
Reputation: AV Manoharan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
AV Manoharan AV Manoharan is offline Offline
Junior Poster

Re: reading records from a .dbf file

  #2  
Jul 20th, 2007
Originally Posted by suneel kar View Post
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 6:17 am.
Reply With Quote  
Join Date: Nov 2006
Posts: 692
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 95
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Master Poster

Re: reading records from a .dbf file

  #3  
Jul 21st, 2007
Hi Suneel,

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

Dim DB As Datbase
Dim RST As RecordSet
Dim sSQL As String
Set DB = DBEngine.OpenDatabase("C:\MyDBFFolder", False, False, "dBASE III;")
sSQL= "Select * From MyTable"
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
Reply With Quote  
Join Date: Jul 2007
Posts: 71
Reputation: suneel kar is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
suneel kar suneel kar is offline Offline
Junior Poster in Training

Re: reading records from a .dbf file

  #4  
Jul 21st, 2007
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









Originally Posted by QVeen72 View Post
Hi Suneel,

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

Dim DB As Datbase
Dim RST As RecordSet
Dim sSQL As String
Set DB = DBEngine.OpenDatabase("C:\MyDBFFolder", False, False, "dBASE III;")
sSQL= "Select * From MyTable"
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
Reply With Quote  
Join Date: Jul 2007
Posts: 71
Reputation: suneel kar is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
suneel kar suneel kar is offline Offline
Junior Poster in Training

Re: reading records from a .dbf file

  #5  
Jul 21st, 2007
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




Originally Posted by suneel kar View Post
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
Reply With Quote  
Join Date: Jul 2007
Location: Philippines
Posts: 160
Reputation: jireh is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 16
jireh's Avatar
jireh jireh is offline Offline
Junior Poster

Re: reading records from a .dbf file

  #6  
Jul 22nd, 2007
Hi vee!
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 7:54 pm.
Reply With Quote  
Join Date: Nov 2006
Posts: 692
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 95
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Master Poster

Re: reading records from a .dbf file

  #7  
Jul 23rd, 2007
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 2:43 am.
Reply With Quote  
Join Date: Jul 2007
Posts: 71
Reputation: suneel kar is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
suneel kar suneel kar is offline Offline
Junior Poster in Training

Re: reading records from a .dbf file

  #8  
Jul 23rd, 2007
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








Originally Posted by QVeen72 View Post
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
Reply With Quote  
Join Date: Nov 2006
Posts: 692
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 95
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Master Poster

Re: reading records from a .dbf file

  #9  
Jul 23rd, 2007
Hi Suneel,

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

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
Reply With Quote  
Join Date: Nov 2006
Posts: 692
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 95
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Master Poster

Re: reading records from a .dbf file

  #10  
Jul 23rd, 2007
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

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

 

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 7:57 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC