Solved

File Name COntains Space

Posted on 2004-04-19
10
954 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
[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
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

730 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