User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 426,517 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,086 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 143211 | Replies: 145
Reply
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 25
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Solution Re: Updated : Simple ASP.Net Login Page

  #101  
May 18th, 2006
Originally Posted by angelicjess
Sorry, I'm kinda noob in this... I do not know how to find out my version of ASP.NET.

I insert Imports.System.Data.SqlClient on top, although the KeyName is no longer showing error but when I used breakpoint, this statement show error >>> Dim MyConn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("strConn"))

Is the information enough?


Ok be sure you have all of the following imports:

When keywords are not recognized, that is the first thing to check.
**Copy and Paste doesn't always solve this**

Imports System.Web.Security ' |||||| Required Class for Authentication
Imports System.Data ' |||||| DB Accessing Import
Imports System.Data.SqlClient ' |||||| SQL Server Import
Imports System.Configuration ' |||||| Required for Web.Config appSettings |||||


And be sure you have this line in your Web.Config file.

<appSettings>
<
add key="strConn" value="Network Library=DBMSSOCN;Data Source=192.168.0.100,1433;database=Northwind;User id=;Password=;"/>
</
appSettings>


Let me know how it goes..
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Join Date: May 2006
Posts: 7
Reputation: angelicjess is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
angelicjess angelicjess is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

  #102  
May 18th, 2006
Sorry, let me give you a clearer picture first. I'm using Access Database and I named my Database as User.mdb. My table is called tblUser. Inside the table got U_id, U_Name and U_Password. I haven't create any Query because the SQL statement you wrote on the first page will always prompt me the value of the parameter. So in the end I deleted it. Is it purpose to be this way?

I also create a Login Page named Login.aspx. My form have:
- txtUsername
- txtPassword
- cmdSubmit
- lblMessage

Thus, I would like to learn from you what should I put for my query and how can I connect to the Access Database so that my login page is workable? I really appreciate your help. =) Thank you in advance!
Reply With Quote  
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 25
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Updated : Simple ASP.Net Login Page

  #103  
May 18th, 2006
Originally Posted by angelicjess
Sorry, let me give you a clearer picture first. I'm using Access Database and I named my Database as User.mdb. My table is called tblUser. Inside the table got U_id, U_Name and U_Password. I haven't create any Query because the SQL statement you wrote on the first page will always prompt me the value of the parameter. So in the end I deleted it. Is it purpose to be this way?

I also create a Login Page named Login.aspx. My form have:
- txtUsername
- txtPassword
- cmdSubmit
- lblMessage

Thus, I would like to learn from you what should I put for my query and how can I connect to the Access Database so that my login page is workable? I really appreciate your help. =) Thank you in advance!

Ok, I can definitely help.

First off I highly recommend you READ through the tutorial again. I am being serious, and not in a bad way.

Why? Your statement:
I haven't create any Query because the SQL statement you wrote on the first page will always prompt me the value of the parameter. So in the end I deleted it. Is it purpose to be this way?


This demonstrates that you may not understanding what the purpose each line of code I have provided is doing. So let me see if I can better clarify what is happening.

To begin this SQL statement used in Access is correct:
SELECT COUNT(*) AS Num_of_User
         FROM tblUser
         WHERE (((tblUser.U_Name)=[@UserName]) AND ((tblUser.U_Password)=[@Password]));

The query is suppose to prompt you; it will in Access as the @UserName & @Password are parameters the query is expecting to do the processing against the database on. What you are doing wanting to do is pass in the values entered into the ASP.NET control (i.e. username & password textboxes) into these paramters. Otherwise how would you provide the query with the values entered? And how else would you qualify the query? Meaning; how would you find out if the password entered is correct for the username entered?

Here is another important point. Your initial error was with the SQLConnection object not being recognized, but you are now saying you are using an Access Database.

Which are you using? An SQL database or Access?

If it is truly Access you are using then the imports you need are those directed at the start of this tutorial:
Imports System.Web.Security     '   ||||||   Required Class for Authentication
Imports System.Data             '   ||||||   DB Accessing Import
Imports System.Data.SqlClient   '   ||||||   SQL Server Import
Imports System.Configuration    '   ||||||   Required for Web.Config appSettings |||||

Link to the start of this tutorial - using an Access Database


Hope this helps.
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Join Date: May 2006
Posts: 7
Reputation: angelicjess is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
angelicjess angelicjess is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

  #104  
May 20th, 2006
I'm Sorry... The login page is still not working. I do not know what went wrong. I'm using Access DB.

Imports System.Web.Security ' |||||| Required Class for Authentication
Imports System.Data ' |||||| DB Accessing Import
Imports System.Data.SqlClient ' |||||| SQL Server Import
Imports System.Configuration ' |||||| Required for Web.Config appSettings |||||

I've changed the above code from Imports.System.Data.SqlClient to Imports.System.Data.OleDBConnection. Because I'm not using SQL Server. Am I right to do so? I've also create a new databse which I had followed the codes on the first page. So could you paste the rest of the codes which I need for me? The first page is kinda confusing for me. I'm really new at this. This is the first time I'm doing this. Please...
Reply With Quote  
Join Date: Jun 2006
Posts: 1
Reputation: E_Hobbie_Coder is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
E_Hobbie_Coder E_Hobbie_Coder is offline Offline
Newbie Poster

Question Re: Updated : Simple ASP.Net Login Page

  #105  
Jun 5th, 2006
Greetings all. I am very green at .net, learning as I go at this point. Is there a way to "adapt" the code here to be usable on the 2.0 Framework? I am building a basic webform for a project at work that pulls a dropdown list from an SQL DB, and I have an editing page to manage it, but of course it needs to be protected so anyone can't just go in and make changes. I build the entire login script based on the notes here, with the usual couple tweaks, but get the error "A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll" when I run in debug mode after entering the name/password. The form always returns the "invalid login!" message regardless as well. I am writing in vb.net 2k5 at this time, but haven't learned all the features as of yet either. -- Thanks for any assistance anyone can provide! --
Reply With Quote  
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 25
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Updated : Simple ASP.Net Login Page

  #106  
Jun 7th, 2006
Originally Posted by E_Hobbie_Coder
Greetings all. I am very green at .net, learning as I go at this point. Is there a way to "adapt" the code here to be usable on the 2.0 Framework? I am building a basic webform for a project at work that pulls a dropdown list from an SQL DB, and I have an editing page to manage it, but of course it needs to be protected so anyone can't just go in and make changes. I build the entire login script based on the notes here, with the usual couple tweaks, but get the error "A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll" when I run in debug mode after entering the name/password. The form always returns the "invalid login!" message regardless as well. I am writing in vb.net 2k5 at this time, but haven't learned all the features as of yet either. -- Thanks for any assistance anyone can provide! --

Hi E_Hobbie_Coder,

You say you are using VB.Net 2K5? Well this code only works with ASP.NET 1.0 or 1.1. It will not function (do to several Framework changes) in ASP.NET 2.0, or VB.NET 2k5 (which would require major code changes to from this tutorial).

Provide the code you are having issues with and I can see what I can do to help.
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Join Date: Jun 2006
Posts: 3
Reputation: shingrey is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
shingrey shingrey is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

  #107  
Jun 17th, 2006
Hi,
I'm new to ASP.net and SQl server,
I'm using VS 2003 and SQL 2005 express edition,
I followed thru out ur tutorial , but still ve problem with building my first login page..

After I click the submit button..lblmessage2.= become visible which is
"Error Connecting to Database!"

I tried playing around with my connection string but its still the same..
my current connection string
<appSettings>
<addkey="strConn"value="Data Source=(local);database=fypDB;User id=;Password=;"/>
</appSettings>

I'm using window authentication...tried several connection string...but i still cannot connect to the db..other then the connection string..others codes are the same as ur tutorial..
Last edited by Paladine : Jun 17th, 2006 at 11:59 am.
Reply With Quote  
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 25
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Updated : Simple ASP.Net Login Page

  #108  
Jun 17th, 2006
try

  <add name="strConn" connectionString="Data Source=P4C800E\SQLEXPRESS;Initial Catalog=pubs;Integrated Security=True"
   providerName="System.Data.SqlClient" />
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Join Date: Jun 2006
Posts: 3
Reputation: shingrey is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
shingrey shingrey is offline Offline
Newbie Poster

Re: Updated : Simple ASP.Net Login Page

  #109  
Jun 17th, 2006
Originally Posted by Paladine
try

  <add name="strConn" connectionString="Data Source=P4C800E\SQLEXPRESS;Initial Catalog=pubs;Integrated Security=True"
   providerName="System.Data.SqlClient" />

I tried the above but error message came out bout missing key, so i replace name with key,..and then another error bout value came out so i replace it,...and now its this error..all this are after the on submit

Parser Error Message: Unrecognized attribute 'providerName'
 
Source Error: 
 
Line 2:  <configuration>
Line 3:      <appSettings>
Line 4:    <add key="strConn" value="Data Source=SHINGREY2\SQLEXPRESS;database=Northwind;Integrated Security=True" providerName="System.Data.SqlClient"/>
Line 5:      </appSettings>Line 6:    <system.web>
 
 
Reply With Quote  
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 25
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Updated : Simple ASP.Net Login Page

  #110  
Jun 17th, 2006
So your datasource is SQLEXPRESS and not some other name?

Also, you have left left the Database as Northwind, and your previous post showed that your database is fypDB So make sure you taylor the string for you specific instance.

Also, the providerName is not required, that was out of ASP.NET 2.0. My apologies, bu the error message tells you what is wrong, so remove the portion that is unrecognized.

The error will occur on the Submit, because that is when the application makes a call to the Database.

Should be: (at least try this)
<addkey="strConn"value="Data Source=(local);Initial Catalog=fypDB;Integrated Security=True""/>
Last edited by Paladine : Jun 17th, 2006 at 1:46 pm.
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 6:06 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC