angelicjess 0 Newbie Poster

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...

angelicjess 0 Newbie Poster

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!

angelicjess 0 Newbie Poster

Ok, What version are you using? ASP.NET 1.0 / 1.1 or ASP.NET 2.0 ? This code will ONLY work on ASP.NET 1.0 & 1.1.

It is saying the SQLConnection, a known Key word is NOT declared, this tells me their is a missed line of code. Have you put in break points and walked through it to see where exactly the error is occuring?

Provide more details or a capture of the exact error message I may be able to help you a little more.

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?

angelicjess 0 Newbie Poster

SQL Variation on the above Simple Login Page in ASP.Net (w/ VB.Net)

8. As in the AccessDB Example of this login page you need to create the DBConnection Function
- You will have to modify the code from the AccessDB example to work for SQL server.
- You will declare a new parameter, add it to the parameter colleciton, and have it set to receive the return value from the stored procedure.
- Determine if the return value is greater than 0 (meaning the SQL DB found the user based on the creditenials provided).

DBConnection Function:

Function DBConnection(ByVal strUserName As String, ByVal strPassword As String) As Boolean
                 '<sumamry>
                 '   |||||   Declare Required Variables
             ' ||||| Access appSettings of Web.Config for Connection String (Constant)
                 '</summary>
                 '   |||||   This is the Connections Object for an SQL DB
                 Dim MyConn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("strConn"))
 
                 '<sumamry>
                 '   |||||   Create a OleDb Command Object
                 '   |||||   Pass in Stored procedure
                 '   |||||   Set CommandType to Stored Procedure
                 '</summary>
 
          ' ||||| To Access a Stored Procedure in SQL Server - Requires a Command Object
                 Dim MyCmd As New SqlCommand("sp_ValidateUser", MyConn)
 
                 MyCmd.CommandType = CommandType.StoredProcedure
                 '   |||||   Create Parameter Objects for values passed in
                 Dim objParam1, objParam2 As SqlParameter
                 '   |||||   Create a parameter to store your Return Value from the Stored Procedure
                 Dim objReturnParam As SqlParameter
                 '<sumamry>
                 '   |||||   Add the parameters to the parameters collection of the
            ' ||||| command object, and set their datatypes (OleDbType in this case)
                 '</summary> 
                 objParam1 = MyCmd.Parameters.Add("@UserName", …
angelicjess 0 Newbie Poster

Sorry, I need some help urgently. I follow the steps u told me but it show:->> C:\Inetpub\wwwroot\OPCWebClient\Login.aspx.vb(42): Name 'SqlConnection' is not declared.

How should I declare this variable?

I still can't connect to the database. Any wrong Username and Password can still use to login. What is wrong?

angelicjess 0 Newbie Poster

Thomas D. Greer,

Thanks for your advice! I'll go and do the research.=)

angelicjess 0 Newbie Poster

Hi All,

May I know how to write the codes to get the correct Username and Password when I Click on "submit" (stored in Access - User_Login.mdb)? Next, how to make the locked the Login Page until I entered the correct Username and Password? Because now even when i type the wrong password and username, it can still redirect the page.

Hope you can help me asap! :)

Cheerz,
angelicjess