Hi,

I am new to dotNET. I want to connect to MSAccess DB from ASP.NET I want
to seperate connectionstring and open the connection just as an object and
properties. I am not able to do that. How can i do?
In every page i want to connect to DB and no need to specify
connectionstring in every page.

And, how can i set the connectionstring in web.config file?

<appSettings>
<add key="appconnection" value="Provider=....;data source=????>

Here we must specify physical path. But with web always must specify virtual
path. How can i set server.mappath here?



</appSettings>

Re: connectionstring by Joyjit

Joyjit
Mon Dec 06 07:35:05 CST 2004

Hi,

you can define your ConnectionString in the Global.asax file under the
Application_start event as a shared variable so that you can assign a shared
connection object to it on every page.

Also, the appsettings element defined under Web.Config file doesn't require
any path mappings, it just contain a key-value pair that you can use in your
code behind files.

Let me know if you need anything else.

regards
Joyjit



"Rajani" <Rajani@discussions.microsoft.com> wrote in message
news:A7040976-286E-45B4-BA6A-BC73D759C9E3@microsoft.com...
> Hi,
>
> I am new to dotNET. I want to connect to MSAccess DB from ASP.NET I
want
> to seperate connectionstring and open the connection just as an object and
> properties. I am not able to do that. How can i do?
> In every page i want to connect to DB and no need to specify
> connectionstring in every page.
>
> And, how can i set the connectionstring in web.config file?
>
> <appSettings>
> <add key="appconnection" value="Provider=....;data source=????>
>
> Here we must specify physical path. But with web always must specify
virtual
> path. How can i set server.mappath here?
>
>
>
> </appSettings>



Re: connectionstring by Sahil

Sahil
Mon Dec 06 07:43:59 CST 2004

Rajani,

In framework 2.0 there is a deprecated class (that used to be internal in
1.1) called DbConnectionString. However there is a better alternative in 2.0
only that should be used - DbConnectionStringBuilder. Though I have heard
plusses and minuses of using such a class - I would personally always use
connectionstring only for the reason that it is plain and simple bytes that
I can change easily - if it were a class, I'd have to set such properties in
code, or have to write code to convert a connectionstring to code - plus you
can write the connectionstring on a peice of paper, tie it do your dog's
collar and ask him to run to another server - but an object is harder to
serialize - anyway that is just my view.

Secondly - you can get around the problem below by using a DSN or a virtual
path. You can then use System.Configuration to read the web.config entries.
However the real problem is that access is not well suited to an asp.net
application. Instead you should look into MSDE - it is free and it is almost
like sql server with a few restrictions - but still better than access for a
multi user environment.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik



"Rajani" <Rajani@discussions.microsoft.com> wrote in message
news:A7040976-286E-45B4-BA6A-BC73D759C9E3@microsoft.com...
> Hi,
>
> I am new to dotNET. I want to connect to MSAccess DB from ASP.NET I want
> to seperate connectionstring and open the connection just as an object and
> properties. I am not able to do that. How can i do?
> In every page i want to connect to DB and no need to specify
> connectionstring in every page.
>
> And, how can i set the connectionstring in web.config file?
>
> <appSettings>
> <add key="appconnection" value="Provider=....;data source=????>
>
> Here we must specify physical path. But with web always must specify
> virtual
> path. How can i set server.mappath here?
>
>
>
> </appSettings>



Re: connectionstring by bsalmonsson

bsalmonsson
Mon Dec 06 16:01:02 CST 2004


A good connection string in web.config would be something like this:

<add key="dsn" value="Data Source=MACHINE001;integrated
security=SSPI;initial catalog="MyDatabaseName />

where MACHINE001 is your computer name (assumes you're running e.g. SQL
Server locally - i.e. not a remote host).
Integrated security=SSPI means that you're using Windows authentication (i.e.
you're authenticated with the database by the user name and password you
use to sign in to Windows - note that your Database server must be installed
at installation with Windows authentication too)

Initial catalog is a fancy term for the name of the database you want to
access
(there can be more than one depending on the database server). In this case
we're saying that we're accessing a database called MyDatabaseName.

Already then...

"Sahil Malik" wrote:

> Rajani,
>
> In framework 2.0 there is a deprecated class (that used to be internal in
> 1.1) called DbConnectionString. However there is a better alternative in 2.0
> only that should be used - DbConnectionStringBuilder. Though I have heard
> plusses and minuses of using such a class - I would personally always use
> connectionstring only for the reason that it is plain and simple bytes that
> I can change easily - if it were a class, I'd have to set such properties in
> code, or have to write code to convert a connectionstring to code - plus you
> can write the connectionstring on a peice of paper, tie it do your dog's
> collar and ask him to run to another server - but an object is harder to
> serialize - anyway that is just my view.
>
> Secondly - you can get around the problem below by using a DSN or a virtual
> path. You can then use System.Configuration to read the web.config entries.
> However the real problem is that access is not well suited to an asp.net
> application. Instead you should look into MSDE - it is free and it is almost
> like sql server with a few restrictions - but still better than access for a
> multi user environment.
>
> - Sahil Malik
> http://dotnetjunkies.com/weblog/sahilmalik
>
>
>
> "Rajani" <Rajani@discussions.microsoft.com> wrote in message
> news:A7040976-286E-45B4-BA6A-BC73D759C9E3@microsoft.com...
> > Hi,
> >
> > I am new to dotNET. I want to connect to MSAccess DB from ASP.NET I want
> > to seperate connectionstring and open the connection just as an object and
> > properties. I am not able to do that. How can i do?
> > In every page i want to connect to DB and no need to specify
> > connectionstring in every page.
> >
> > And, how can i set the connectionstring in web.config file?
> >
> > <appSettings>
> > <add key="appconnection" value="Provider=....;data source=????>
> >
> > Here we must specify physical path. But with web always must specify
> > virtual
> > path. How can i set server.mappath here?
> >
> >
> >
> > </appSettings>
>
>
>

Re: connectionstring by Sahil

Sahil
Mon Dec 06 16:55:23 CST 2004

> where MACHINE001 is your computer name (assumes you're running e.g. SQL
> Server locally - i.e. not a remote host).

She's using Access

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik




"bsalmonsson" <bsalmonsson@discussions.microsoft.com> wrote in message
news:E283C3B2-BB24-40CD-8C92-69592ABF8C04@microsoft.com...
>
> A good connection string in web.config would be something like this:
>
> <add key="dsn" value="Data Source=MACHINE001;integrated
> security=SSPI;initial catalog="MyDatabaseName />
>
> where MACHINE001 is your computer name (assumes you're running e.g. SQL
> Server locally - i.e. not a remote host).
> Integrated security=SSPI means that you're using Windows authentication
(i.e.
> you're authenticated with the database by the user name and password you
> use to sign in to Windows - note that your Database server must be
installed
> at installation with Windows authentication too)
>
> Initial catalog is a fancy term for the name of the database you want to
> access
> (there can be more than one depending on the database server). In this
case
> we're saying that we're accessing a database called MyDatabaseName.
>
> Already then...
>
> "Sahil Malik" wrote:
>
> > Rajani,
> >
> > In framework 2.0 there is a deprecated class (that used to be internal
in
> > 1.1) called DbConnectionString. However there is a better alternative in
2.0
> > only that should be used - DbConnectionStringBuilder. Though I have
heard
> > plusses and minuses of using such a class - I would personally always
use
> > connectionstring only for the reason that it is plain and simple bytes
that
> > I can change easily - if it were a class, I'd have to set such
properties in
> > code, or have to write code to convert a connectionstring to code - plus
you
> > can write the connectionstring on a peice of paper, tie it do your dog's
> > collar and ask him to run to another server - but an object is harder to
> > serialize - anyway that is just my view.
> >
> > Secondly - you can get around the problem below by using a DSN or a
virtual
> > path. You can then use System.Configuration to read the web.config
entries.
> > However the real problem is that access is not well suited to an asp.net
> > application. Instead you should look into MSDE - it is free and it is
almost
> > like sql server with a few restrictions - but still better than access
for a
> > multi user environment.
> >
> > - Sahil Malik
> > http://dotnetjunkies.com/weblog/sahilmalik
> >
> >
> >
> > "Rajani" <Rajani@discussions.microsoft.com> wrote in message
> > news:A7040976-286E-45B4-BA6A-BC73D759C9E3@microsoft.com...
> > > Hi,
> > >
> > > I am new to dotNET. I want to connect to MSAccess DB from ASP.NET I
want
> > > to seperate connectionstring and open the connection just as an object
and
> > > properties. I am not able to do that. How can i do?
> > > In every page i want to connect to DB and no need to specify
> > > connectionstring in every page.
> > >
> > > And, how can i set the connectionstring in web.config file?
> > >
> > > <appSettings>
> > > <add key="appconnection" value="Provider=....;data source=????>
> > >
> > > Here we must specify physical path. But with web always must specify
> > > virtual
> > > path. How can i set server.mappath here?
> > >
> > >
> > >
> > > </appSettings>
> >
> >
> >