|
|
|
date: Tue, 15 Apr 2008 20:37:00 -0700,
group: microsoft.public.platformsdk.internet.server.isapi-dev
back
Re: Database connection
Hi,
i dont know how things work on here and if anyone is allowed to give
answers, but please anyone let me if am not supposed to.
when you run an app from the desktop it runs as the logged in user, so you
would have given him permissions on the database and thats why you dont get
any errors, but when you run it as a web app from IIS, it will run depending
on the settings in IIS, more likely as default would be allow anonymous so
it would be using the IUSR_machinename.
you can use one of those 2 options to sort it out.
1. give the anonymous user IUSR_ permissions on the database that are
required to run the app.
2. save a username and a password that have access to the database in the
connection string of your application.
Imad
"Sonu" <sonu@online.nospam> wrote in message
news:11C8C719-0C96-45C3-B87F-E55976C4CC3E@microsoft.com...
> Hi,
> I have been trying to figure this out without any success :( Please
> help...
>
> I have been trying to establish a connection with the SQL server 2005
> Express database on my server through an ISAPI dll.
> Now if I use the same code and put it in a Windows desktop connection and
> put it on the server and run it on the Remote desktop. It connects and
> runs
> an SQL string.
> BUT, when I try to make the connection from my ISAPI application, I get
> the
> error:
>
> Cannot open database "DatabaseName" requested by the login. The login
> failed. Login failed for user ServerName\IUSR_TEMPLATE'.
>
> Here is the code:
>
> try
> {
> CDatabase db;
> CString connectionstring=_T("Driver={SQL Native
> Client};Server=ServerName\\SQLEXPRESS;Database=DatabaseName;Trusted_Connection=yes;");
> if (db.OpenEx (connectionstring, CDatabase::noOdbcDialog))
> {
> *pCtxt<<"Connected";
> db.Close();
> }
> else
> {
> *pCtxt<<"Not Connected";
> }
> }
> catch(CDBException *e)
> {
> *pCtxt<<e->m_strError;
> e->Delete();
> }
>
>
> What am I doing wrong? As I said, the same code works fine with a desktop
> application!!! Am I doing something wrong or is there something wrong with
> the databse setup?
> Please please help!!!
> Thanks os very much
> Srishti
date: Wed, 16 Apr 2008 16:32:50 +0100
author: Imad
Re: Database connection
Dear Imad,
Thank you so so so very much!!! :D
I made a userlogin IUSR_TEMPLATE for the dtatabse I was trying to connect to
and gave it the permission to read and write. And it worked!!! Thanks again
so much for your help.... And yes, I think anyone can post any help here!
Thanks again
Srishti :D
"Imad" wrote:
> Hi,
> i dont know how things work on here and if anyone is allowed to give
> answers, but please anyone let me if am not supposed to.
> when you run an app from the desktop it runs as the logged in user, so you
> would have given him permissions on the database and thats why you dont get
> any errors, but when you run it as a web app from IIS, it will run depending
> on the settings in IIS, more likely as default would be allow anonymous so
> it would be using the IUSR_machinename.
> you can use one of those 2 options to sort it out.
> 1. give the anonymous user IUSR_ permissions on the database that are
> required to run the app.
> 2. save a username and a password that have access to the database in the
> connection string of your application.
>
> Imad
>
>
> "Sonu" <sonu@online.nospam> wrote in message
> news:11C8C719-0C96-45C3-B87F-E55976C4CC3E@microsoft.com...
> > Hi,
> > I have been trying to figure this out without any success :( Please
> > help...
> >
> > I have been trying to establish a connection with the SQL server 2005
> > Express database on my server through an ISAPI dll.
> > Now if I use the same code and put it in a Windows desktop connection and
> > put it on the server and run it on the Remote desktop. It connects and
> > runs
> > an SQL string.
> > BUT, when I try to make the connection from my ISAPI application, I get
> > the
> > error:
> >
> > Cannot open database "DatabaseName" requested by the login. The login
> > failed. Login failed for user ServerName\IUSR_TEMPLATE'.
> >
> > Here is the code:
> >
> > try
> > {
> > CDatabase db;
> > CString connectionstring=_T("Driver={SQL Native
> > Client};Server=ServerName\\SQLEXPRESS;Database=DatabaseName;Trusted_Connection=yes;");
> > if (db.OpenEx (connectionstring, CDatabase::noOdbcDialog))
> > {
> > *pCtxt<<"Connected";
> > db.Close();
> > }
> > else
> > {
> > *pCtxt<<"Not Connected";
> > }
> > }
> > catch(CDBException *e)
> > {
> > *pCtxt<<e->m_strError;
> > e->Delete();
> > }
> >
> >
> > What am I doing wrong? As I said, the same code works fine with a desktop
> > application!!! Am I doing something wrong or is there something wrong with
> > the databse setup?
> > Please please help!!!
> > Thanks os very much
> > Srishti
>
>
date: Wed, 16 Apr 2008 11:07:01 -0700
author: Sonu am
Re: Database connection
you're welcome, glad i could help.
Imad
"Sonu" <sonu@online.nospam> wrote in message
news:25460A18-B8EF-4777-8A7F-A4F941280A7C@microsoft.com...
> Dear Imad,
> Thank you so so so very much!!! :D
> I made a userlogin IUSR_TEMPLATE for the dtatabse I was trying to connect
> to
> and gave it the permission to read and write. And it worked!!! Thanks
> again
> so much for your help.... And yes, I think anyone can post any help here!
> Thanks again
> Srishti :D
>
> "Imad" wrote:
>
>> Hi,
>> i dont know how things work on here and if anyone is allowed to give
>> answers, but please anyone let me if am not supposed to.
>> when you run an app from the desktop it runs as the logged in user, so
>> you
>> would have given him permissions on the database and thats why you dont
>> get
>> any errors, but when you run it as a web app from IIS, it will run
>> depending
>> on the settings in IIS, more likely as default would be allow anonymous
>> so
>> it would be using the IUSR_machinename.
>> you can use one of those 2 options to sort it out.
>> 1. give the anonymous user IUSR_ permissions on the database that are
>> required to run the app.
>> 2. save a username and a password that have access to the database in the
>> connection string of your application.
>>
>> Imad
>>
>>
>> "Sonu" <sonu@online.nospam> wrote in message
>> news:11C8C719-0C96-45C3-B87F-E55976C4CC3E@microsoft.com...
>> > Hi,
>> > I have been trying to figure this out without any success :( Please
>> > help...
>> >
>> > I have been trying to establish a connection with the SQL server 2005
>> > Express database on my server through an ISAPI dll.
>> > Now if I use the same code and put it in a Windows desktop connection
>> > and
>> > put it on the server and run it on the Remote desktop. It connects and
>> > runs
>> > an SQL string.
>> > BUT, when I try to make the connection from my ISAPI application, I get
>> > the
>> > error:
>> >
>> > Cannot open database "DatabaseName" requested by the login. The login
>> > failed. Login failed for user ServerName\IUSR_TEMPLATE'.
>> >
>> > Here is the code:
>> >
>> > try
>> > {
>> > CDatabase db;
>> > CString connectionstring=_T("Driver={SQL Native
>> > Client};Server=ServerName\\SQLEXPRESS;Database=DatabaseName;Trusted_Connection=yes;");
>> > if (db.OpenEx (connectionstring, CDatabase::noOdbcDialog))
>> > {
>> > *pCtxt<<"Connected";
>> > db.Close();
>> > }
>> > else
>> > {
>> > *pCtxt<<"Not Connected";
>> > }
>> > }
>> > catch(CDBException *e)
>> > {
>> > *pCtxt<<e->m_strError;
>> > e->Delete();
>> > }
>> >
>> >
>> > What am I doing wrong? As I said, the same code works fine with a
>> > desktop
>> > application!!! Am I doing something wrong or is there something wrong
>> > with
>> > the databse setup?
>> > Please please help!!!
>> > Thanks os very much
>> > Srishti
>>
>>
date: Wed, 16 Apr 2008 21:37:00 +0100
author: Imad
|
|