Solved

ado dbf connection string doesnt accept spaces?

Posted on 2002-04-16
11
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

717 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