.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Login that checks against a sql database

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :ASP.Net

Creating a login for a website that checks against a database table.

I have never made a login before but im just going with what i think would be right.



but how do i make it check against a database? and how do i capture that login and use it again in the next page?

Sorry if all of this is wrong im very new to asp.net!


View Complete Post

More Related Resource Links

Login database with visual studio 2010 asp website template


Has anyone deployed a website using the login database in the visual studio 2010 asp website template? I was wondering if I could look at someone's example to see how the integrated this into their website.

Database login set up issue

Hi folks, I have more than one domains trusted each other, one user has already been granted access in the server, but I don't see it using Exec  xp_logininfo. I even tried adding the user as sysadmin. no problem for most of other users from the same domain. For another user, when I run the Exec  xp_logininfo, it returns: Msg 15404, Level 16, State 11, Procedure xp_logininfo, Line 62 Could not obtain information about Windows NT group/user 'INTL\RTxie', error code 0x534. what happened to these two accounts? is it a SQL issue or Active Directory issue? That domain has 15000 accounts across over 100 domain controllers. my domain has roughly the same amount users. they are trusted each other under same forest. Thank you in advance.

Cannot open database "ReportServer$SQLEXPRESS" requested by the login. The login failed. (App Log Ev

I have SQL'08r2x64 freshly installed on a WS'03r2x64sp2 box and WS is also a DC (sorry).  Previously, there was a SQL'05sp3 installation on this box and it worked splendito.  I used the SQL'05 for some minor devel and to host a Backup Exec 11D db/installation; it all was splendito.   Then, i removed SQL'05&BE11D to prepare for an upgrade of this arrangement.  Next, i installed said SQL'08 to be the foundation for a planned Backup Exec 12.5 install.  To date, I can't get to a clean install of SQL'08 and thus have not progressed to installing BE12.5.  I now have this painfully annoying situation (as i've been beating on it for 2 days) where a series of errors occur during boot: 1st: srmSvc; Event ID 12317; File Server Resource Manager failed to enumerate share paths or DFS paths.  Mappings from local file paths to share and DFS paths may be incomplete or temporarily unavailable.  FSRM will retry the operation at a later time. 2nd & 3rd (occurs twice): MsSQL$buExpressSQL; Event ID 18456; Login failed for user 'BOWMAN\ExecSQL'. Reason: Failed to open the explicitly specified database. [CLIENT: <local machine>] 4th: Report Server Windows; Event ID 107; Report Server Windows Service (SQLEXPRESS) cannot connect to the report server database. I couldn't find anything to sink my teeth into for the 12317 error; i

need a simple login page cus my hosting provider system wont allow me to have more than one database

I dont really write html code too well  but I manged to get my web site developed and deployed using the built in features such as drag n drop, master page and user account authentication that make web developing almost a codeless experience. However; my hosting provider system wont allow me to have more than one database, this causes problems becasue when I developed my web app using vb2010 web developer (asp.net v2) I used the built in web config tool to manage users for my site, now after I deployed to my domain it all worked ok with the exeption of the login page, when I tried to log in the system threw a error message saying "database not found." or a page of "gobble-dee-gook" that says the same thing When I contacted support (my hosting provider) they said i have to create a table of users in my database file via 2008 sql server, thats ok I can do that, but my real problem is I dont know how to write appropriate code to reference the table. So heres my problem:  I just want to have some kind of login page with a couple of txtboxes and a click button that maybe using the VB code behind or html checks the input variables "username" "password" against something that is hard coded into vb a string variable or a constant and then branches to Mainmenu.aspx if successfull. I just need it real simple, no fancy stuff just a login s

Cannot open database " " requested by the login. The login failed.

Hi, I am trying to take the backup of the sitecolletion using stsadm -o command, getting the following error. Cannot open database "dbName " requested by the login. The login failed. Login failed for user  'User'. Any help appriciated. Thanks Srikanth Reddy

Writing a login page that checks against AD Credentials

Hey everyone: Just a quick question hopefully someone can help me out with.  I'm trying to write a simple login page, that will allow my users to login to my site using their Active Directory credentials (using their username / password we give them through AD).  I want to do 2 things with the login: 1. I want to check the username / password against our AD and verify the person is a valid user within the directory. 2. I also want to store the entry within a global variable so when the user fills out one of the forms within the site it can Insert the data into a SQL table i have running.  ** we are using this site to do Setup Change Request Forms / Termination forms etc. and I just want to verify the person signing off on the form is the person logged into the machine -- use it as an "electronic signature per say". I'm using a vb.net 2.0 approach - as i only have access to visual studio 2005 and i'm more of a vb programmer then a c#. If anyone has any examples or can walk me through how to go about writing out this page that would be great.  Thanks everyone - the help is appriciated in advance.  Best regards, Ryan 

Can I have an SQL Express database open in VS2010E along with the website? "Login failed for user ..

Hi, as the topic says..Whenever I have my database open in Visual Studio 2010 Express, I get this error:Cannot open user default database. Login failed.Login failed for user 'IIS APPPOOL\DefaultAppPool'.Cannot open user default database. Login failed.Login failed for user 'IIS APPPOOL\DefaultAppPool'.

Login to Database from Application

Hello, On my SQL Server I have the Security and Logins section.  I usually do the following to access the database from my application: 1 - Create a database on dbo scheme; 2 - Create a Login; 3 - Create a Database Role in the Database and grant the following permissions:      select, insert, update, delete, execute on schema::dbo 4 - Create a Database User and associate it to the Database role and to the Login  Then on my MVC application I use a Connection String with the login to access the database. Can I access the database without the login? Should I make this in some other way? Thank You, Miguel

Cannot open database "dbTest" requested by the login. The login failed.

Hi,All Hi, all      I meet a problem and an error: Cannot open database "dbTest" requested by the login. The login failed.Login failed for user 'machinename'. The condition is like this: 1 I make my website connect to a remote sql server. 2 This sql server makes only access to a count, such as 'sa' and its password is 'sapw' 3 I write the connect string in web.config like this : <add name="ConnectionString" connectionString="Data Source=dbTestSource;Initial Catalog=dbTest;Integrated Security=True;    User ID=sa;Password=sapw;"    providerName="System.Data.SqlClient" />   But the error says "Login failed for user 'machinename'". How could I make my website access to the sql server with the account of "sa"?  

MVC Login Database

I have started a new MCV application in Visual Web Developer 2010 express. I have an administration controller. I want a page that shows the administrator all the users on the site (using the default database - accessed from the ASP.NET Web Application Administration Tool) and give him controls to edit and delete users and create new users. I have no idea of how to do this as I am relatively new to ASP.NET. Any ideas?I am writing the website in C#. Also, on the ASP.NET Web Application Administration Tool, when managing access rules, it says: "Rules that appear dimmed are inherited from the parent and cannot be changed at this level.". What does this mean and how do I change them?

Adding Current Windows User to Database Encounters Existing User with Same Login


In VS2008 in debug mode, I am using SMO to programatically change the users and permissions on a database. Windows authentication alone is being used. I need to limit access to a administrators group and the current user for whom the database has been dynamically created during the first run of the application within their current Windows environment on the machine. I have no problems creating and assigning the administrators group, but when I try to create the user using the environment's UserDomainName and UserName variables (which would be my creditals) I encounter an inner exception "The login already has an account under a different user name". Before doing running the app, I manually have checked the local server for user and logins with my credentials and programatically looked at each login but have not found any matching credentials. 

Insights and suggestions appreciated.


How to add a login to a specific database?

A login has server level securityadmin and dbcreator roles. This login needs to add another login to a specific database as a user with db_owner database role. The problem is that when the securityadmin & dbcreator tries to execute "USE database" he/she gets an access error message because the login isn't a user in the database. If the login has sysadmin role then he/she has access to the database. Is there a workaround in order not to give sysadmin role to the login?

Cannot open database "db" requested by the login. The login failed. Login failed for user 'NT AUTHO


I am working with visual studio 2010, ms sql server 08 R2, IIS 7.5, I am trying to connect to the database the following error appear every time I try to open the connection with the server:

Cannot open database "db" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: Cannot open database "db" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

Source Error: 

Line 47:             //    "','&qu

Membership Provider - Login fails after change in database name


Hi Experts,

I am in the process of deploying an website developed in ASPNet 2.0 and using the login control and membership provider features. The site was deployed fine and was working perfectly till I changed the database name and user name to access the database. I changed the accordingly in the web.config to point to the new database. Everyting is working file except when the user tries to login into the website.

The error log says that login failed because it is trying to open the old database.

Any idea how I can solve the issue? Thanks for your help.



Create Two Login From Two DataBase " Help"



I want to create 2 login actionresults  from 2 user's tables, one user's table is from aspnetdb.mdf and its for admin and its already created by MVC itself,

 the other user's table is from my own database and I want to create it for general users "subscribers "

So,How can I do that?

thanks b4

Login that checks with DB

    private bool VerifyPassword(string suppliedUserName, string suppliedPassword)
        bool passwordMatch = false;
        // Get the salt and pwd from the database based on the user name.
        // See "How To: Use DPAPI (Machine Store) from ASP.NET," "How To:
        // Use DPAPI (User Store) from Enterprise Services," and "How To:
        // Create a DPAPI Library" for more information about how to use
        // DPAPI to securely store connection strings.
        string connectionString = (string)ConfigurationSettings.AppSettings["BusinessIntelligence"];
        SqlConnection sqlConnection = new SqlConnection(connectionString);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = sqlConnection;

        cmd.CommandType = System.Data.CommandType.StoredProcedure;
        //Usage of Sql parameters also helps avoid SQL Injection attacks.
        SqlParameter sqlParam = cmd.Parameters.Add("@Username", SqlDbType.VarChar, 20);
        sqlParam.Value = suppliedUserName;
            SqlDataReader reader = cmd.ExecuteReader();
            reader.Read(); // Advance to the one and only row
            // Return output parameters from returned data stream
            string dbPasswordHash = reader.GetString(0);

Cannot open database "ProjectServer_Draft" requested by the login.


I have a Project Web App installed that is attached to ProjectServer_Draft2 database. In the past however I have had it point to 'ProjectServer_Draft'. This database is now deleted however in the event logs i can still the follwing error message.

Cannot open database "ProjectServer_Draft" requested by the login.

Please advise how can i get rid of this error.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend