473,394 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to use ASP for working .DBF files ?

Also idea ?

how to use ASP for working .DBF files ?

Please help me ..

thanks

Vivian
Jul 19 '05 #1
3 12272
Hi Viviane....

check out this link....

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

It should give you all the info you need.

Best
Tom Gahagan

Jul 19 '05 #2
Querying and extracting data is relatively easy with the right connection
string.

Here's my function for returning an ADODB.Connection for a DBF (using ADO
and the Jet 4.0 OLEDB Provider):

Public Function GetDBFConnection(ByVal strHubFilename As String, Optional
ByVal strDBFUserID As String, Optional ByVal strDBFPwd As String, Optional
ByVal plngTimeoutSeconds As Long, Optional ByVal penumCursorLocation As
Integer = adUseClient) As ADODB.Connection
Dim connPrivate As ADODB.Connection
Dim strConn As String
Dim strSource As String
Dim plngCount As Long
Dim pstrErrMessage As String

'Create the connection object
Set connPrivate = New ADODB.Connection
Set GetDBFConnection = New ADODB.Connection
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
strHubFilename & ";Persist Security Info=True;Extended Properties=dBase IV"
connPrivate.ConnectionString = strConn
connPrivate.CursorLocation = penumCursorLocation
If plngTimeoutSeconds > 0 Then connPrivate.ConnectionTimeout =
plngTimeoutSeconds
On Error GoTo Try_Again
Err.Clear
plngCount = 0
Try_Again:
plngCount = plngCount + 1
If plngCount > 5 Then GoTo Error_Occurred
connPrivate.Open
On Error GoTo 0
Set GetDBFConnection = connPrivate
Set connPrivate = Nothing
Exit Function
Error_Occurred:
pstrErrMessage = S_ERR_RSACCESS_CONNECTION & vbCrLf
pstrErrMessage = pstrErrMessage & "Connection String = '" & strConn &
"'" & vbCrLf
pstrErrMessage = pstrErrMessage & "Line " & Erl & " - " &
Err.Description & vbCrLf & "in RSFunctionsADODB.GetDBFConnection." & vbCrLf
Err.Clear
Err.Number = ERR_RSACCESS_CONNECTION
Err.Description = pstrErrMessage
Err.Raise Err.Number
End Function

Just to be clear, the folder that the DBF's reside in is considered the
'database' (or 'catalog') and each DBF file is treated as a table within
that database. So .. in the above .. strHubFilename is actually the folder
that the DBF is within and the SQL statement uses the name of the DBF (no
extension) as the table that it's querying.

Now, I usually get disconnected recordsets and update them by reconnecting
them and calling .UpdateBatch on the recordset. However, I've never
successfully managed to update a DBF (on it's own with no index file etc.)
so I'm not 100% certain how to achieve it. If I need to do that then I
usually convert the DBF to Access (using the pstrh component) and work on it
as a standard Access database. There's obviously an over head to this
though.

This is the function that I generally use to get a recordset for a DBF:

Public Function GetDBFRS(ByVal strQuery As String, ByVal strHubDBFFilename
As String, Optional strDBFUserID As String, Optional ByVal strDBFPwd As
String, Optional ByVal plngTimeoutSeconds As Long, Optional ByVal
penumCursorLocation As Integer = adUseClient) As ADODB.Recordset
Dim privateRS As ADODB.Recordset
Dim privateConn As ADODB.Connection
Dim strSource As String
Dim plngCount As Long
Dim pstrErrMessage As String

'Create the ADODB.Recordset
Set GetDBFRS = New ADODB.Recordset
Set privateRS = New ADODB.Recordset
Set privateConn = New ADODB.Connection
Set privateConn = GetDBFConnection(strHubDBFFilename, strDBFUserID,
strDBFPwd, plngTimeoutSeconds, penumCursorLocation)
If plngTimeoutSeconds > 0 Then privateConn.CommandTimeout =
plngTimeoutSeconds
Set privateRS.ActiveConnection = privateConn
On Error GoTo Try_Again
plngCount = 0
Try_Again:
Err.Clear
plngCount = plngCount + 1
If plngCount > 5 Then GoTo Error_Occurred
DoEvents
privateRS.Open strQuery, privateConn, adOpenStatic,
adLockBatchOptimistic
On Error GoTo 0
If privateConn.CursorLocation = adUseClient Then
Set privateRS.ActiveConnection = Nothing
End If
Set GetDBFRS = privateRS
Set privateRS = Nothing
Set privateConn = Nothing
Exit Function
Error_Occurred:
pstrErrMessage = S_ERR_RSACCESS_RECORDSET & vbCrLf
pstrErrMessage = pstrErrMessage & "Connection String = '" &
privateConn.ConnectionString & "'" & vbCrLf
pstrErrMessage = pstrErrMessage & "SQL Statement = '" & strQuery & "'" &
vbCrLf
pstrErrMessage = pstrErrMessage & "Line " & Erl & " - " &
Err.Description & vbCrLf & "in RSFunctionsADODB.GetDBFRS." & vbCrLf
Err.Clear
Err.Number = ERR_RSACCESS_RECORDSET
Err.Description = pstrErrMessage
Err.Raise Err.Number
End Function

Notice that it calls the first function to get the connection and then drops
the connection immediately afterward - this is the beauty of disconnected
recordsets - they do not consume database connection resources unless
actually doing something and they can also be persisted to disk or sent to a
remote application. There is enough infromation inside the recordset to
allow it to function 'disconnected' from the database.

It shouldn't be too hard to implement this in VBScript - just drop the
variable types and make sure that the constants are correct.

Hope this helps (a bit).

NB: If you want to see the entire DLL that contains this function (and those
for Access and SQL Server) then download it from:

http:\\ftp.belper.blue-canoe.net\RSAccess\RSAccess.zip

Cheers,

Chris.

"viviane lima - * - * -" <vi*********@ligbr.com.br> wrote in message
news:ed**************@TK2MSFTNGP12.phx.gbl...
Chris

Yes, i want queries, updates, delete records but in the tools
I can work this ?

thanks

Vivian

"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> escreveu na mensagem
news:uR**************@TK2MSFTNGP12.phx.gbl...
Query or update? (update is harder - I've never got it to work successfully without converting to an Access DB and then back again on the fly).
Check out

http://www.pstruh.cz/help/RSConv/database.asp

for the tool that does that (it's very good).

I have a VB class that will do reads and queries - it's easily ported to
VBScript if necessary (and indeed I may have already done it somewhere) if
you need it.

Chris.

"viviane lima - * - * -" <vi*********@ligbr.com.br> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Also idea ?

how to use ASP for working .DBF files ?

Please help me ..

thanks

Vivian


Jul 19 '05 #3
Man nice. Thank you Chris.

--
George Hester
__________________________________
"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> wrote in message news:u0**************@TK2MSFTNGP12.phx.gbl...
Querying and extracting data is relatively easy with the right connection
string.

Here's my function for returning an ADODB.Connection for a DBF (using ADO
and the Jet 4.0 OLEDB Provider):

Public Function GetDBFConnection(ByVal strHubFilename As String, Optional
ByVal strDBFUserID As String, Optional ByVal strDBFPwd As String, Optional
ByVal plngTimeoutSeconds As Long, Optional ByVal penumCursorLocation As
Integer = adUseClient) As ADODB.Connection
Dim connPrivate As ADODB.Connection
Dim strConn As String
Dim strSource As String
Dim plngCount As Long
Dim pstrErrMessage As String

'Create the connection object
Set connPrivate = New ADODB.Connection
Set GetDBFConnection = New ADODB.Connection
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
strHubFilename & ";Persist Security Info=True;Extended Properties=dBase IV"
connPrivate.ConnectionString = strConn
connPrivate.CursorLocation = penumCursorLocation
If plngTimeoutSeconds > 0 Then connPrivate.ConnectionTimeout =
plngTimeoutSeconds
On Error GoTo Try_Again
Err.Clear
plngCount = 0
Try_Again:
plngCount = plngCount + 1
If plngCount > 5 Then GoTo Error_Occurred
connPrivate.Open
On Error GoTo 0
Set GetDBFConnection = connPrivate
Set connPrivate = Nothing
Exit Function
Error_Occurred:
pstrErrMessage = S_ERR_RSACCESS_CONNECTION & vbCrLf
pstrErrMessage = pstrErrMessage & "Connection String = '" & strConn &
"'" & vbCrLf
pstrErrMessage = pstrErrMessage & "Line " & Erl & " - " &
Err.Description & vbCrLf & "in RSFunctionsADODB.GetDBFConnection." & vbCrLf
Err.Clear
Err.Number = ERR_RSACCESS_CONNECTION
Err.Description = pstrErrMessage
Err.Raise Err.Number
End Function

Just to be clear, the folder that the DBF's reside in is considered the
'database' (or 'catalog') and each DBF file is treated as a table within
that database. So .. in the above .. strHubFilename is actually the folder
that the DBF is within and the SQL statement uses the name of the DBF (no
extension) as the table that it's querying.

Now, I usually get disconnected recordsets and update them by reconnecting
them and calling .UpdateBatch on the recordset. However, I've never
successfully managed to update a DBF (on it's own with no index file etc.)
so I'm not 100% certain how to achieve it. If I need to do that then I
usually convert the DBF to Access (using the pstrh component) and work on it
as a standard Access database. There's obviously an over head to this
though.

This is the function that I generally use to get a recordset for a DBF:

Public Function GetDBFRS(ByVal strQuery As String, ByVal strHubDBFFilename
As String, Optional strDBFUserID As String, Optional ByVal strDBFPwd As
String, Optional ByVal plngTimeoutSeconds As Long, Optional ByVal
penumCursorLocation As Integer = adUseClient) As ADODB.Recordset
Dim privateRS As ADODB.Recordset
Dim privateConn As ADODB.Connection
Dim strSource As String
Dim plngCount As Long
Dim pstrErrMessage As String

'Create the ADODB.Recordset
Set GetDBFRS = New ADODB.Recordset
Set privateRS = New ADODB.Recordset
Set privateConn = New ADODB.Connection
Set privateConn = GetDBFConnection(strHubDBFFilename, strDBFUserID,
strDBFPwd, plngTimeoutSeconds, penumCursorLocation)
If plngTimeoutSeconds > 0 Then privateConn.CommandTimeout =
plngTimeoutSeconds
Set privateRS.ActiveConnection = privateConn
On Error GoTo Try_Again
plngCount = 0
Try_Again:
Err.Clear
plngCount = plngCount + 1
If plngCount > 5 Then GoTo Error_Occurred
DoEvents
privateRS.Open strQuery, privateConn, adOpenStatic,
adLockBatchOptimistic
On Error GoTo 0
If privateConn.CursorLocation = adUseClient Then
Set privateRS.ActiveConnection = Nothing
End If
Set GetDBFRS = privateRS
Set privateRS = Nothing
Set privateConn = Nothing
Exit Function
Error_Occurred:
pstrErrMessage = S_ERR_RSACCESS_RECORDSET & vbCrLf
pstrErrMessage = pstrErrMessage & "Connection String = '" &
privateConn.ConnectionString & "'" & vbCrLf
pstrErrMessage = pstrErrMessage & "SQL Statement = '" & strQuery & "'" &
vbCrLf
pstrErrMessage = pstrErrMessage & "Line " & Erl & " - " &
Err.Description & vbCrLf & "in RSFunctionsADODB.GetDBFRS." & vbCrLf
Err.Clear
Err.Number = ERR_RSACCESS_RECORDSET
Err.Description = pstrErrMessage
Err.Raise Err.Number
End Function

Notice that it calls the first function to get the connection and then drops
the connection immediately afterward - this is the beauty of disconnected
recordsets - they do not consume database connection resources unless
actually doing something and they can also be persisted to disk or sent to a
remote application. There is enough infromation inside the recordset to
allow it to function 'disconnected' from the database.

It shouldn't be too hard to implement this in VBScript - just drop the
variable types and make sure that the constants are correct.

Hope this helps (a bit).

NB: If you want to see the entire DLL that contains this function (and those
for Access and SQL Server) then download it from:

http:\\ftp.belper.blue-canoe.net\RSAccess\RSAccess.zip

Cheers,

Chris.

"viviane lima - * - * -" <vi*********@ligbr.com.br> wrote in message
news:ed**************@TK2MSFTNGP12.phx.gbl...
Chris

Yes, i want queries, updates, delete records but in the tools
I can work this ?

thanks

Vivian

"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> escreveu na mensagem
news:uR**************@TK2MSFTNGP12.phx.gbl...
Query or update? (update is harder - I've never got it to work

successfully
without converting to an Access DB and then back again on the fly).
Check out

http://www.pstruh.cz/help/RSConv/database.asp

for the tool that does that (it's very good).

I have a VB class that will do reads and queries - it's easily ported to
VBScript if necessary (and indeed I may have already done it somewhere) if
you need it.

Chris.

"viviane lima - * - * -" <vi*********@ligbr.com.br> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Also idea ?

how to use ASP for working .DBF files ?

Please help me ..

thanks

Vivian



Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Moosebumps | last post by:
So say I am working on two separate .py files in IDLE that are part of the same program. Does anyone have problems where when you modify one file, and then run the other, the changes you made in...
4
by: Jerry | last post by:
I'm having just a bit of trouble wrapping my brain around the task of working with folders that are above the site's root folder. I let users upload photos (.jpg/.gif files) which can...
14
by: Mark B | last post by:
Our webhost (www.usbusinessweb.net) had a W2K IIS5 server crash after a scheduled hard-boot occurred during a ms-security patch install overnight. They couldn't get the server working again so they...
6
by: Matt Frame | last post by:
I have a client that has asked us to get a digital signature certificate and start digitally signing all files we pass between each other. I have heard of the subject and know about the certs but...
4
by: Axter | last post by:
Sorry for OT question, but does any one have a working *.bat file to get Comeau to work with VC++ 7.1, VC++ 8.0, or GNU 3.x compilers. I've tried everything I can think off, to get it to work,...
1
by: saturday | last post by:
I was having problems getting mysql to work with php on my apache server. Thankfully I got it working after reading a different thread, which had me copy over the libmysql file to the apache/bin...
0
by: George2 | last post by:
Hello everyone, From the definition of working set, it is a subset of virtual pages resident in physical memory -- from book Windows Internals. It means working set could not be larger than...
5
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a machine running IIS 6.0. I just replaced the web.config and several aspx pages in the application and now the style sheets are not working. the images from the themes work but not the css...
3
by: Seth Williams | last post by:
I have done some new development on older files, locally - then I copy the files, along with the .vb files for the webservices, to our DEV server. Now, mysteriously, no web services are running - I...
6
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.