I am currently working on ASP and wants to establish a trusted connection with database (i.e. SQL Server 2000 in my case)


Can any one help me out.


Thanks

Qasim

I would do the following. In the session_onstart section of global.asa put the following code:

Session("dbConnectionString") = "DSN=DSNNAME;DATABASE=DATABASENAME"
Session("dbConnectionTimeout") = 60
Session("dbCommandTimeout") = 300
Session("dbRuntimeUserName") = "Username"
Session("dbRuntimePassword") = "password"

then, on any page when you need to open a connection
just use:

Set conObject = Server.CreateObject("ADODB.Connection")
	conObject.ConnectionTimeout = Session("dbConnectionTimeout")
	conObject.CommandTimeout = Session("dbCommandTimeout")
	conObject.Open Session("dbConnectionString"), Session("dbRuntimeUserName"), Session("dbRuntimePassword")

Even in this case you mentioned to me we need to right username and password in global.asa

what i am expecting to find a way to not provide username and password any where in the code. I have heard that there are some settings in the IIS through which we can handle this. The idea was about to create a service account there in IIS and writting Trusted Connection in db connection string.

But to do that. I am not aware of that.

Any one know about this Service Account setup there in IIS.
Please do let me know.


Thanks
Qasim

why do you really need to have a trusted connection? if the site is https and the hosting company is straight (or trusted users only on the computer) its secure enough. the username and password is not sent in the content / pages. its all handled on the server. to get added protection ssl the trafic from the webserver to the database server.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.