Solved

File Name COntains Space

Posted on 2004-04-19
10
953 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 51

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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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