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

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

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


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

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

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

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?

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

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

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

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

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

hi veena .
con.open statement worked.
"rs.Open Text1.Text, con, adOpenForwardOnly, adLockOptimistic"
what it does actually.reply
regards
suneel


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

hi veena
is it possible that text1.txt can contain CHECK_2045.pdf.
can i give the name of folder directly where CHECK_2045 is present.
CHECK_2045 is present in C:\Suneel_development\New Folder\record reading\CHECK_2045.pdf
may i write like this
"rs.Open CHECK_2045.pdf, con, adOpenForwardOnly, adLockOptimistic
it is giving object required error.
wt to do here
regards
suneel

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

hi Suneel,

In the above Program, con is the Connection Object which allows u to connect to the Database. Since Database has many sets of tables, u will have to use RecordSet object to access data.

check this :
rs.Open "Select * from MyTable", con, adOpenForwardOnly, adLockOptimistic

here RS is the Recordset object which actuualy holds Table Data, this is opened thru Con object.
CHECK_2005 should be .dbf File and Is actually the Table and u r opening it thru recordset.

u cannot open PDF files with ADO in VB6


Regards
Veena

hi veena
we cannot open PDF files with ADO in VB6.is it so.
i placed CHECK_2045.dbf In MyTable and tried ur cde buttttt it could not find the MyTable
if u dont mind may i send u my project.
reply soon

Hi,

Create Folder "MyDBF" in C
and place all dbfs's there in ("c:\MyDBF")
and use this code:

con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDBF; Extended Properties=DBase IV"
rs.Open "Select * from CHECK_2005", con, adOpenForwardOnly, adLockOptimistic

Yes, u can send me the project. I will modify and return back.


Regards
Veena

hi i was waitin for ur reply but u went offline. hey how to send projct to u.may i have ur mail id where i can send it .
reply now
regards
suneel

Hi,

Create Folder "MyDBF" in C
and place all dbfs's there in ("c:\MyDBF")
and use this code:

con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDBF; Extended Properties=DBase IV"
rs.Open "Select * from CHECK_2005", con, adOpenForwardOnly, adLockOptimistic

Yes, u can send me the project. I will modify and return back.


Regards
Veena

Hi,

U can Zip and upload the proj here, or i have sent u pvt msg abt my email id

Regards
Veena

hi veena
if possible give me ur gmail id i will be thankful to u.
regards
suneel kar

Hi Vee,

you know I'm confused, why we dont need to mention the dbf file but only their path?

the connection is now ok but there's still a problem on me here why I can't use it in a query? here's my code for that dbf.

Set db = OpenDatabase(App.Path & "\", False, False, "dBase IV;")
Set Data1.Recordset = db.OpenRecordset("select * from color where clrcode='" & Text1.Text & "'")

Is there something I should add in my query?
The error is in here

Set Data1.Recordset = db.OpenRecordset("select * from color where clrcode='" & Text1.Text & "'")

hello gud mornin dear
veena is there any website which can guide me or provide tutorial for vb topic wise.
if any then plz do reply
regards
suneel

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

hello bro
may i know the name of any website which gives nline tutorial of vb topicwise
reply
regards
suneel

hello veena
i am sendin u the code see wts problem in this.
it is givvin "unrecognized database format" error.
reply plzz.
code is
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 & "\RR.dbf ; Persist Security Info=False"
rs.Open RR, con, adOpenForwardOnly, adLockOptimistic
Dim str As String
If Dir("c:\Suneel_Development\New Folder\New Folder\data.txt") <> "" Then
Kill "c:\Suneel_Development\New Folder\New Folder\data.txt"
End If
Open "c:\Suneel_Development\New Folder\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

hello veena
they r sayin itis already installed .not required also.
regards
suneel

Hi,

Why dont u install it once again and try..., as i told u it doesnt install on its own..

Regards
Veena

HEY VEENA
itna gussa nt good .i was just sayin na ki conecrned persons told methat it is already installed.
anyways thanx
suneel

This question has already been answered. Start a new discussion instead.