Creating temporary database on user's PC.

J

Jerry Spence1

Why doesn't the following work in my ASP program? I have imported ADOX

I am trying to create a temporary database on the user's PC. The example is
taken from Microsoft.

Dim cat As Catalog = New Catalog

cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=C:\NewMDB.mdb;" & _

"Jet OLEDB:Engine Type=5")

It comes up with the error

"The Microsoft Jet database engine cannot open the file 'C:\NewMDB.mdb'. It
is already opened exclusively by another user, or you need permission to
view its data."

This is all on my PC
 
D

Dimitri Glazkov

Could you explain the architecture of your program a little better? Why are
you creating this database? What will it be used for? By whom?

:DG<
 
J

Jerry Spence1

Dimitri Glazkov said:
Could you explain the architecture of your program a little better? Why
are you creating this database? What will it be used for? By whom?

Thanks Dimitri

My company produces its own IP Based security solution for surveillance and
access control (Software and hardware). What I am trying to do is to create
an interactive web site that will allow a prospective customer to select the
card readers he needs (RFID, Card swipe etc), select the camera models
(Infrared, Internal, Dome etc) and this will give him a list of parts with
prices (including Power over Ethernet, Video over Ethernet components, video
server etc). I was thinking of creating, on the fly, a database on his PC
for temporarily storing his selected information (a bit like a relational
'basket' so that when he presses a button, he will get a complete list of
parts, with quanities and total price for the whole project.

I am sure there are probably other ways (and better) for doing this but I
have no experience of Internet programming and don't know how it all
normally fits together. I am an experienced VB.Net programmer though.

I can't work out why I can't seem to create the database on the local PC
drive and why I am getting that strange error message.

Thanks

-Jerry
 
D

Dimitri Glazkov

Jerry,

You will not (and should not) be able to create a database on user's
computer. This goes against all principles of secure computing -- imagine
what would happen if other Web sites were be able to create files on your
hard drive at will.

There is a fundamental architectural difference in the way you approach Web
programming vs. Desktop. On the Web, the browser is a stateless serialized
view of the application.You can use things like cookies to simulate state,
but basically, the rule of thumb is that you store actual user data on the
server and only leave the identifying cookie with the user. When the user
logs in, your server reads the cookie and is able of retrieving user data
that corresponds with that cookie.

To implement authentication/authorization, I recommend looking into ASP.NET
Forms or Windows authentication.

From there, you can develop a database, where user data is stored using user
Id as a key.

It's not a simple task, and I would highly recommend studying ASP.NET
architecture patterns before doing anything.

This is where MSDN library becomes your best friend.

:DG<
 
J

Jerry Spence1

Hi Dimitri

Many thanks for that excellent explanation. So I will create the database on
the server.

I'm a bit puzzled how it knows where to create it. The default location of
my project is

C:\Inetpub\wwwroot\WebApplication1\

and when I run it, it loads with
http://localhost/WebApplication1/WebForm1.aspx in the explorer bar. But when
it runs in real life for others it will be
http://myexternalIPaddress/Something

so what is the syntax for the connection string? clearly it can't be this:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=//localhost/NewMDB.mdb;Jet
OLEDB:Engine Type=5"

Thanks

-Jerry
 
D

Dimitri Glazkov

Jerry,

In the example below, the location should be:
C:\Intetpub\wwwroot\WebApplication1\NewMDB.mdb

However, it really does not matter where you create the database, as long as
the ASP.NET process has read/write permissions to the directory in which the
database is placed. If you run your application with impersonation disabled,
the ASP.NET process will access this database using aspnet account.
Otherwise, it will attempt to use the account with which the user logged in.

One of things to consider is the fact that now you are in fact writing a
multithreaded, concurrent-access application. More than one user at a time
may be accessing your Web site and thus more than one access/modification of
your database may occur simultaneously. MS Access may not be your best
solution, as it was not designed to handle enterprise-strength concurrent
operations. Look into using MS SQL server or at least MSDE engine.

:DG<
 
J

Jerry Spence1

Thanks. I was thinking of using a separate database per user. In anycase the
volume will be very low due to the specialised subject (I wish it were't!)

I tried the path you suggested and yes it worked! Thanks a lot.

-Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top