Solved

File Name COntains Space

Posted on 2004-04-19
10
952 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 50

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

773 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