Solved

ado dbf connection string doesnt accept spaces?

Posted on 2002-04-16
11
257 Views
Last Modified: 2007-11-27
i m using this connection string but
when the user select sourcedb = some path where
there are spaces in between the directory eg
"c:\thework\i   know\test.dbf"  i will get an error!
how to resolve this error?

oConn.Open "Driver={Microsoft Visual FoxPro Driver};" & _
                   "SourceType=DBF;" & _
                   "SourceDb=\somepath\mySourceDb.dbf;" & _
                   "Exclusive=No;"
0
Comment
Question by:spiral
  • 5
  • 4
  • 2
11 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6945658
Have you tried:

oConn.Open "Driver={Microsoft Visual FoxPro Driver};" & _
                  "SourceType=DBF;" & _
                  "SourceDb=""\somepath\mySourceDb.dbf;""" & _
                  "Exclusive=No;"
0
 

Author Comment

by:spiral
ID: 6946485
yes i have tried but not working
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6946499
is it possible that you cannot specify the dbf file into the connection string (you will name it into the query)?

see http://www.able-consulting.com/ADO_Conn.htm#ODBCDriverForVisualFoxPro
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6947100
You can use the dbf file in the connection string if you ensure that you use adCmdTable in the recordset.Open statement. You could always use the shortpath form of the path:

Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Public Function GetShortPath(ByVal FileName As String) As String
    Dim lngRes As Long, strPath As String
    strPath = String$(165, 0)
    lngRes = GetShortPathName(FileName, strPath, 164)
    GetShortPath = Left$(strPath, lngRes)
End Function

....

oConn.Open  "Driver={Microsoft Visual FoxPro Driver};" & _
                 "SourceType=DBF;" & _
                 "SourceDb=" & GetShortPathName(""c:\thework\i   know\") & "test.dbf;" & _
                 "Exclusive=No;"
0
 

Author Comment

by:spiral
ID: 6947536
what does GetShortPathName do?
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6947580
It returns the 8.3 path name that represents the path you are using for example:

c:\Program Files\Microsoft Visual Studio\VB98

becomes

c:\Progra~1\Micros~1\VB98

Which never includes spaces and should be understandable in win9x,NT,2000,XP
0
 

Author Comment

by:spiral
ID: 6948350
ok thanks i will try it out tomorrow
0
 

Author Comment

by:spiral
ID: 6949388
TimCottee: it works thank u. but when i try to rename my folder which has spaces to other filename directory, it doesnt allow me. how to release the kernel32.dll which was
accessing it previously?
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6949852
spiral, can you explain that? You don't need to rename your folder to the 8.3 version as these are equivalent and refer to the SAME folder just in different ways. Wherever you use the fullpath you can use the shortpath in the same place.
0
 

Author Comment

by:spiral
ID: 6950138
i meant when i run my program under the vb6 development environment, everything is ok but when i unload my program
go to windows explorer and rename the folder which i previously accessed, i cant rename it. I need to shut down vb6 and then i can rename the file folder. why is this so?

it says the file folder is still in use. but i already unload my program! is the kernel32 causing this problem?
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6950156
Kernel32 has nothing to do with this. My guess is that you have not properly terminated the ADO objects that you have instantiated. Ensure that you do oConn.Close and oRst.Close and then Set oConn = Nothing and Set oRst = Nothing when you have finished using the objects.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Restricting text box entry from \/:?<>"| 9 86
Search combo error "Data Type Mismatch in Criteria Expression" 2 61
Add and format columns in vb6 7 56
RUNRMTCMD from AS/400 12 46
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question