Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 12th, 2003, 11:25 AM
maugusto maugusto is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brazil
Posts: 8 maugusto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking Accessing memo fields in a DBF

Hi, guys

How can i access memo fields in a DBF using a VB aplication

Thanks.

Reply With Quote
  #2  
Old October 13th, 2003, 12:50 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Use DAO or ADO to access MSaccess files..add ms dao control into your project..
U can visit the msdn web:http://msdn.microsoft.com/library/d...n_adorosest.asp

Reply With Quote
  #3  
Old October 13th, 2003, 08:12 AM
maugusto maugusto is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brazil
Posts: 8 maugusto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ADO/DAO

Cleverpig, i can to access .mdb tables using DAO or ADO, be cool, my problem is just how can i access .DBF tables that have memo fields using ADO

Thanks.

Reply With Quote
  #4  
Old October 13th, 2003, 10:04 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
OK! U will access DBF file??..
This is a way:
1. Create connection to open DBF files
We can use several providers to open DBF files usind ADODB. Basic way is to use ODBC data source (DSN or DSNless), there is several samples published on web. But how to open DBF files without ODBC? There are two other OLEDB providers, using which you can work with DBF files. One of them is Microsoft.Jet.OLEDB.
Key property to work with DBF files is "Extended Properties" - there is no much info about this parameter in documentation. This parameter has similar meaning as connect parameter in DAO OpenDatabase method. First work is to open connection to DBASE IV files:
Function OpenDBFConn(Path)
Dim Conn: Set Conn = CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Path & ";" & _
"Extended Properties=""DBASE IV;"";"
Set OpenDBFConn = Conn
End Function

2. Other ISAM formats, FoxPro
"DBASE IV" is one of ISAM format. You can find installed ISAM formats in

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\ISAM Formats\
registry key. You can use other formats - "dBase 5.0", "Paradox 3.X", "Outlook 9.0" etc.
But what about FoxPro files? Microsoft.Jet.OLEDB.4.0 does not support FoxPro 2.0 - 3.0 as ISAM parameter - you cannot see this ISAM engine in Jet\4.0\ISAM Formats lists. You can do some small work around of this feature - import FoxPro ISAM from Jet\3.5 key. Create small .reg file with the next information:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\ISAM Formats\FoxPro 3.0]
"Engine"="Xbase"
"ExportFilter"="Microsoft FoxPro 3.0 (*.dbf)"
"CanLink"=hex:00
"OneTablePerFile"=hex:01
"IsamType"=dword:00000000
"IndexDialog"=hex:00
"CreateDBOnExport"=hex:00
"ResultTextExport"="Export data into a Microsoft FoxPro 3.0 file."
"SupportsLongNames"=hex:00


Then you can use
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Path & ";" & _
"Extended Properties=""FoxPro 3.0;"";"



3. Work with DBF connection
So, what we can do with the connection? You can use any ODBC statement (Create table, Insert Into, Delete, Select ...). You can address the table using several ways:

Select * from Persons
Select * from Persons.DBF
Insert Into Persons#DBF Values (...)
Delete * from [Persons.DBF] Where ...

Create Table [Any Long File Name You Want] As ...


4. Real VBS samples
Open DBF connection, create table, insert records, get recordset.


'Open connection For DBF files In F:\ folder
Dim DBConn
Set DBConn = OpenDBFConn("f:\")

'Create a new DBF file named Persons.DBF
DBConn.Execute "Create Table Persons (Name char(50), City char(50), Phone char(20), Zip decimal(5))"

'Insert some row To the table
DBConn.Execute "Insert into Persons Values('Alex P. Nor', 'Mexico','458962146','14589')"

'Open recordset from Persons table
Dim Persons
Set Persons = DBConn.Execute("Select * from [Persons#DBF]")

'Output the recordset In csv format
Wscript.Echo Persons.GetString(,-1, ", ", vbCrLf)


Plz Visit http://www.pstruh.cz/tips/detpg_asp-dbf-database.htm

Reply With Quote
  #5  
Old October 13th, 2003, 10:17 AM
maugusto maugusto is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brazil
Posts: 8 maugusto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Memo fields in .DBF tables

Cleverpig, thanks for your suggestion, but i have one more question: using that, can i really access .DBF tables that have MEMO fields ? Can i read datas from these fields using SQL statements (SELECT), for example ?

Reply With Quote
  #6  
Old October 13th, 2003, 10:47 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Yes u can do it,if u use recordset variable to get it.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Accessing memo fields in a DBF


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT