Using Process.Start()!

BigSi

Newcomer
Joined
Feb 6, 2003
Messages
22
Hi,

Im using the Process.Start method to open Access which is working ok until I use the arguments.

Currently to open a specific access database, i use:
Visual Basic:
System.Diagnostics.Process.Start("MSAccess.exe", "'C:\mydatabase\databasename")
This works fine, but when i have a directory with a space in it such as

'my database'

I get an error as access looks for the .mdb file called 'my'!

Is there a way to prevent the space causing this error by suplementing the space character with some thing else?

cheers,
Si
 
Visual Basic:
Dim MyDatabase as string = "MyDB.mdb"

System.Diagnostics.Process.Start("MSAccess.exe", "C:\mydatabase\" & MyDatabase)

Andy
 
Sorry Andy,
I think I havn't clearly said what the problem is!

the following code works fine as there is no space in the directory name:
Visual Basic:
System.Diagnostics.Process.Start("MSAccess.exe", "'C:\mydatabase\databasename")
but this code doesn't as there is a space in the directory name
Visual Basic:
System.Diagnostics.Process.Start("MSAccess.exe", "'C:\my database\databasename")

I am trying to find out if there is something I should subsititute for the space character such as my%database/databasename
 
what you can do is the 8 char naming system

e.g.

Visual Basic:
System.Diagnostics.Process.Start("MSAccess.exe", "c:\mydata~1\databasename")

This will work. What was done was the parameter was truncated because a space existed. truncate to 8 chars.

Or

The best method is to double quote

Visual Basic:
System.Diagnostics.Process.Start("MSAccess.exe", """c:\my database\databasename""")

Both will work

Also just to note: you has a apostrophe in there with invaildates the path


Andy
 
Andy,

Thanks for your help andy - the double quote worked perfectly! - the only problem now is that I should have mentioned I was working with variables so the location of the mdb file could be anything!

Do you know if there is a way to adapt the double quote to use it alongside a string variable?

Otherwise I guesse I'm gonna have to break down all the directories and discover which ones have spaces, so I can convert them to the 8 char naming system.


Once again - thanks for your help!

(oh - and that apostraphe should not have been there, I accidently put it on whilst posting this message. well spotted though!)
 
yup

Visual Basic:
Dim MyPath As String = Application.Startupparth & "\"
Dim MyDatabaseName As String = "MyName.mdb"

System.Diagnostics.Process.Start("MSAccess.exe", """" & MyPath & MyDatabaseName & """")

That will work fine

Andy
 
Hurray!!

- just found a way to use a string variable!
Visual Basic:
Dim DatbaseLocation as string
DatabaseLocation = "C:\my database\databasename"
DatabaseLocation = """" & databaseLocation & """"

System.Diagnostics.Process.Start("MSAccess.exe", DatabaseLocation)

Thanks again Andy for your help!
 
Back
Top