Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

File Name COntains Space

Posted on 2004-04-19
10
Medium Priority
?
956 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 53

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
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 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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

688 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