Solved

File Name COntains Space

Posted on 2004-04-19
10
949 Views
Last Modified: 2010-05-18
Hi All,
  I am using VbScript to access a MS Access Database and Pulling the information from Access to SQL Server.I am not using DSN instead i formed the Connection String to open the MS Access.The problem is the file Name(MDB) contains Space(Say for example "my database.mdb").I couldnt access MS Access Databse since it is having Space.any solution for this.if so please post ur comments immediately.

Regards
Venkat
0
Comment
Question by:N_K_venkat
10 Comments
 

Author Comment

by:N_K_venkat
ID: 10865813
Hi All,
File Name is "My database.mdb".One Way to solve this problem is recent copy this file and rename it as mydatabase.mdb and i can write a code to access renamed file to get the data.i dont want to use this method...i want to form connection string for this mdb file and i need to access data.

Regards
Venkat
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 10866028
Can you post your VBScript here?..
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10866685
name = replace(name,vbspace,"")


try something like that :)
WORD TO YAH MOTHER!!!!!


-Brian
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:Pi7
ID: 10867290
In the connection string of the connection object specify something like:
.ConnectionString =".......;Data Source = " & "C:\My Database.mdb".
Forexample if you are using a reference to an ADO object and cn is a reference to and ADO connection object then you'll have something like:
cn.ConnectionString = "<Specify details>;Data Source = " &  "C:\My Database.mdb"  
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 10868240
Try putting a single qoute around the filename:

'My Database.mdb'
0
 

Author Comment

by:N_K_venkat
ID: 10875301
Hi vinnyd79,
  I tried with Single Quoates but still it is not working.File is in the Network Path.I can go by DSN Connection but for this particular project i couldnt go to that.File Name is given from the Batch File which calls this VB Script FIle.This is a schedular which pulls data from MDB to Sql Server.

Regards
Venkat
0
 
LVL 1

Accepted Solution

by:
JTrain earned 125 total points
ID: 10875723
Use the short path name...

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(strFileName As String) As String
    Dim lngReturnCode As Long
    Dim strPath As String
    'Create a buffer
    strPath = String(165, 0)
    'retrieve the short pathname
    lngReturnCode = GetShortPathName(strFileName, strPath, 164)
    'remove all unnecessary chr$(0)'s
    GetShortPath = Left(strPath, lngRes)
End Function

so replace your current filename with getshortpath(the.db) and it should work
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now