Showing posts with label login. Show all posts
Showing posts with label login. Show all posts

Monday, March 26, 2012

One Application With 2 DataBase

Hai All ,

Iam having the one Application in DotNet2005.But iam using the two database(SqlServer2005).If user's login the application it will check credentials in first database, if he is not having the login credentials it will cheek the second Database. How can I handle in the configuration file?. How can I change the connection string depending upon the Database in my application for database operation (like insert and update).Any one kindly provide the solution.

Thanks and regards,sureshK

you can have 2 separate connection string in web.config file, appsetting section like

<add key="loginConnectionString" value = "" />

<add key="ConnectionString" value="" />

you can check have a Session Variable named as "CurrentLogin" where you can store the ID or Name or anything user related information after successful login.. if user is logged in.. then that Session Variable must having Some Value.. you can check that value and;... set and use required Connection String by you... hope i got your situation...

|||

Hai Thank You. Your answer is exactly Correct. If their is any other way to achieve this?.

With Regards,

SureshK.|||

Hi mskumarmca,

Just askaushalparik27 has suggested above, you can use two different connection string to connect to 2 databases, and in your code behind, first build one connecton to the first database and execute your query. If the specific username/password has been found, it indicates that the current user is registered in the first dabase. And if not, you can build another connection to the second database and execute the same query likewise.

A small tip here: you can provide 2 check boxes in the page UI, giving users a change to select on which database they would like to verify their credential. This should be much helpful to enhance your site performance.

Hope my suggestion helps

|||

Hi thank for your tips.

Yes I get database name and passing the database name as parameter and finished.

But I am trying to keep the Database name in session. But I am not able to get that session value in my BL layer.

For change the connection string for further database operations. Below code was I am trying to get database value in BL Layer class file. But the session value is set as Null. What is the problem?

String DBName=(String)System.Web.HttpContext.Current.Session["DBNAME"];

Kindly give me the idea. Regards,SureshK|||

where and how did you store that DBNAME into your session variables?

|||

Hi thanks for your reply,

When the user log in the application. I will connect through default connection string with DB1.

I have one SP to check login cardinals in DB1 and DB2 and it will return the login cardinals and connection string name.

if user name is DB1 I am going to use ConsStr1 else Constr2. That Connection string value in login page.

Session["DBNAME"] = dsLogin.Tables[0].Rows[0][DBNAME].ToString();

Above session value only i need to access in my business logic layer.

Regards,

SureshK

|||

Hai all I Got the answer.

In BL Class file .

Import the namesapce.

using System.Web.SessionState;

And Following is to access the session Variable.

string SapId = (String)System.Web.HttpContext.Current.Session["session variale name in asp.cs"];

Monday, March 12, 2012

ole server login dialog box

I am trying to connect to sql server 2000 from a windows
95 machine and windows 98. Both give me the same problem.
There is no server listing in the login dialog box and it
won't allow me to type it in. The error is unable to
connect to data source.
The workaround is to code it in the registry, but that is
not acceptable.
The connection works fine in windows 2000, NT and XP.
Any ideas?
Thanks.What dialog box are you referring to? Are you talking about registering the
server in Enterprise Manager? Connecting through Query Analyzer? Can you
use OSQL and pass the server name as -S?
What does "won't allow me to type it in" mean? Do you get an error or it
won't let you click inside the dialog box?
What exactly do you add to the registry to make it work (what key and what
value)?
Cindy Gross, MCDBA, MCSE
http://cindygross.tripod.com
This posting is provided "AS IS" with no warranties, and confers no rights.

Monday, February 20, 2012

old question about login, but no help from the existing threads

osql -d adventureworks2000 -U admin -P admin
Login failed for user 'admin'. Reason: Not associated with a trusted SQL
Server connection.
My system and configurations:
- Winxp + sp2
- mssql developer edition + sp3a
- Windows Authentication only
- Local System Account is used to start the sql instance
- admin/admin is the administrator account to login to the xp box
- admin/admin was added to "SQL Server Group/[Machine Name]/Security/Log
ins"
with the database access and all database role assigned to the database in
question.
- admin/admin was added to "Databases/[database in question]/Users, with
Permit in Database Role all checked.
Am I missing anything?
Thanks> - Windows Authentication only
osql -d adventureworks2000 -E
AMB
"man-in-nature" wrote:

> osql -d adventureworks2000 -U admin -P admin
> Login failed for user 'admin'. Reason: Not associated with a trusted SQL
> Server connection.
> My system and configurations:
> - Winxp + sp2
> - mssql developer edition + sp3a
> - Windows Authentication only
> - Local System Account is used to start the sql instance
> - admin/admin is the administrator account to login to the xp box
> - admin/admin was added to "SQL Server Group/[Machine Name]/Security/L
ogins"
> with the database access and all database role assigned to the database in
> question.
> - admin/admin was added to "Databases/[database in question]/Users, wi
th
> Permit in Database Role all checked.
> Am I missing anything?
> Thanks
>

Old problem, but... Cannot open user default database. Login failed. Login failed for user '

I didn't use SQL Express before, now I am trying to use it. I thinkk it is convinient if you just want to copy db files to user's machine. like this

<add name="schsecurity" connectionString="Data Source=.\SQLExpress;Integrated Security=true;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" />

as long as user has sql express installed, he should be able to use the db once he copy the file aspnetdb.mdf over.

but when I tried it, I got

Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

it looks simple, SQL express can not verify user 'NT AUTHORITY\NETWORK SERVICE'

so I connect SQL express with SQL server management studio, and add the user into login of the SQL express and set the user as sysadmin. But I still get the error.

Any idea?

thanks!

I doubt it has anything to do with copying files to your machine. The default database does not have proper permissions for access. I receive the same message when attempting to log in using username and password. I know the username and password are correct. I'm not sure of how to give the default db permission for access.|||

You should not post like that, it is not helpful.

Can anyone help?

thanks