By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,344 Members | 1,139 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,344 IT Pros & Developers. It's quick & easy.

Loading an Access database in code

P: n/a
Ian
Hi everyone,

I am trying to create a vb program which, among other things, will open
a new copy of MS Access (with a custom copy of the system.mdw) and load
a database. I have been trying to utilise the
System.Diagnostics.Process.Start function, but this fails to correctly
load the required system.mdw. Does anyone have any ideas?

Thanks in advance,

Ian

Nov 21 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Ian,

Is this what you mean?

http://www.windowsformsdatagridhelp....1-d6dda3c888c8

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
Ian
Thanks for the response Cor.

It isn't quite what I mean - I don't want to control the database from
within my VB program, I just wish to load access and then stop running
the VB program. Part of the function of this program is to provide an
intelligent database loader, and in effect, replacing the current
shortcut (which calls: "C:\Program Files\Microsoft
Office\OFFICE11\MSACCESS.EXE" "S:\Database.mdb" /wrkgrp
"S:\system.mdw").

Thanks again,

Ian

Nov 21 '05 #3

P: n/a
Ian,

Can you than show the code of that application.start, because that
applications start with as path the dbs should (normally) start access.

Cor
Nov 21 '05 #4

P: n/a
Ian
Hi Cor,

I'm not sure what you mean? What I would like to acheive is basically
an application load command which calls LOAD("C:\Program
Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "S:\Database.mdb" /wrkgrp
"S:\system.mdw") (or equivalent).

Ian

Nov 21 '05 #5

P: n/a
Ian,

You wrote this
System.Diagnostics.Process.Start

And this should in my opinion go

System.Diagnostics.Process.Start("c:\Ian.dbf")
if that dbf exist and is on C

(If you have the proper rights of course to that file, if you don't see it
in that location in explorer you wont be able to use it).

Here bellow a more complete one if you want to try that one

\\\Notepad
Dim p As New Process
Dim pi As New ProcessStartInfo
pi.arguments = "c:\windows\win.ini"
pi.FileName = "notepad.exe"
p.startinfo = pi
p.Start()
\\\

Cor

"Ian" <ia*********@maps-eu.com> schreef in bericht
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi Cor,

I'm not sure what you mean? What I would like to acheive is basically
an application load command which calls LOAD("C:\Program
Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "S:\Database.mdb" /wrkgrp
"S:\system.mdw") (or equivalent).

Ian

Nov 21 '05 #6

P: n/a
Ian
Hi Cor,

I think that I am now starting to get there. I have looked at your code
and am happy with how it is working. I have also modified it to
correctly load the database:
\\\Database
Dim p As New Process
Dim pi As New ProcessStartInfo
With pi
.FileName = "C:\Program Files\Microsoft
Office\OFFICE11\MSACCESS.EXE "
.Arguments = "C:\Database.mdb /wrkgrp C:\system.mdw /user
USER /pwd PWD"
End With
p.StartInfo = pi
p.Start()
\\\
This works perfectly. However, once I had tested this and was happy it
was working, I then changed the link to reflect the true location of
the database on a network share not my own PC - at that point, Access
refused to load the database. It claims that I am trying to open Access
with an incorrect startup option.

Thanks again for the assistance.

Ian

Nov 21 '05 #7

P: n/a
Ian
Hi Cor

I have been playing around and now found out that the problem now is
spaces in the folder names. Is there anything that I can do about this?

Thanks,

Ian

Nov 21 '05 #8

P: n/a
Ian
I have now sorted the problem by cunning use of the old MSDOS format
for dealing with long filenames. Thanks for all your help!

Ian

Nov 21 '05 #9

P: n/a
Cor, I was looking at your example in the link you gave and didn't understand
this part of the table creation statement:

"CONSTRAINT [pk_AutoId] PRIMARY KEY (AutoId))

What does this do (don't understand what pk_AutoID is?
--
Dennis in Houston
"Cor Ligthert [MVP]" wrote:
Ian,

Is this what you mean?

http://www.windowsformsdatagridhelp....1-d6dda3c888c8

I hope this helps,

Cor

Nov 21 '05 #10

P: n/a
Why don't you post the code that you finally got to work..it would be
appreciated.
--
Dennis in Houston
"Ian" wrote:
I have now sorted the problem by cunning use of the old MSDOS format
for dealing with long filenames. Thanks for all your help!

Ian

Nov 21 '05 #11

P: n/a
Dennis,

It is an old sample of me. I should change this sample for to use with an
Guid and not an autokey Guid.

I am don't like (better hate) SQL. However in my opinion is to keep this
code to keep the key unique.
http://msdn.microsoft.com/library/de...eate2_8g9x.asp

I hope this helps,

Cor

"Dennis" <De****@discussions.microsoft.com> schreef in bericht
news:7A**********************************@microsof t.com...
Cor, I was looking at your example in the link you gave and didn't
understand
this part of the table creation statement:

"CONSTRAINT [pk_AutoId] PRIMARY KEY (AutoId))

What does this do (don't understand what pk_AutoID is?
--
Dennis in Houston
"Cor Ligthert [MVP]" wrote:
Ian,

Is this what you mean?

http://www.windowsformsdatagridhelp....1-d6dda3c888c8

I hope this helps,

Cor

Nov 21 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.