| | |
help newbie alert needs help with login page
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2005
Posts: 3
Reputation:
Solved Threads: 0
Wasn't sure whether to put this in the beginners section or here, so sorry if this is in the wrong section. basicly i'm trying to create a simple login page (not too simple obviously). basicly i use the query shown bellow to gain the userID: SELECT UserID FROM tblUsers WHERE UserName=@Username AND Password=@Password;
Then on my login page i connect to the database and envoke the procedure setting the parameters etc before using the TRY block to attempt to validate the user, essentialy i have an integer intID thats set to 0 and that should be updated if the user details are correct (to another number) but it never does and so currently no-one is authorised to access my site if anyone can just take a look bellow and tell me where i'm screwing up i'd be very gratefull, i am a newbie to this so so it'll prob be something really dumb:
dim conn as new OleDbConnection("Provider=" & _
"Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=M:\FYP\project.mdb")
dim objCmd as OleDbCommand = new OleDbCommand _
("spValidateUser", Conn)
objCmd.CommandType = CommandType.StoredProcedure
dim objParam as OleDbParameter
objParam = objCmd.Parameters.Add("@Username", OleDBType.BSTR)
objParam.Value = tbUsername.Text
objParam = objCmd.Parameters.Add("@Password", OleDBType.BSTR)
objParam.Value = tbPassword.Text
try
objCmd.Connection.Open
intID=CType(objCmd.ExecuteScalar, Integer)
objCmd.Connection.Close
catch ex as OleDbException
lblMessage.text = ex.Message
end try
if intID <> 0 then
Response.Cookies("authorise").Value = IntID
Response.redirect("main2.aspx")
else
lblMessage.Text = "<font color=red>Sorry, " & "invalid username of password </font><p>"
end if
end sub
Then on my login page i connect to the database and envoke the procedure setting the parameters etc before using the TRY block to attempt to validate the user, essentialy i have an integer intID thats set to 0 and that should be updated if the user details are correct (to another number) but it never does and so currently no-one is authorised to access my site if anyone can just take a look bellow and tell me where i'm screwing up i'd be very gratefull, i am a newbie to this so so it'll prob be something really dumb:
dim conn as new OleDbConnection("Provider=" & _
"Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=M:\FYP\project.mdb")
dim objCmd as OleDbCommand = new OleDbCommand _
("spValidateUser", Conn)
objCmd.CommandType = CommandType.StoredProcedure
dim objParam as OleDbParameter
objParam = objCmd.Parameters.Add("@Username", OleDBType.BSTR)
objParam.Value = tbUsername.Text
objParam = objCmd.Parameters.Add("@Password", OleDBType.BSTR)
objParam.Value = tbPassword.Text
try
objCmd.Connection.Open
intID=CType(objCmd.ExecuteScalar, Integer)
objCmd.Connection.Close
catch ex as OleDbException
lblMessage.text = ex.Message
end try
if intID <> 0 then
Response.Cookies("authorise").Value = IntID
Response.redirect("main2.aspx")
else
lblMessage.Text = "<font color=red>Sorry, " & "invalid username of password </font><p>"
end if
end sub
So what is the issue? Is the if intID <> 0 giving you an issue?
My advice is take a look at the link in my sig to the UPDATED: ASP.Net Login Page, as it will give you code that is similar and may explain some things for you.
My advice is take a look at the link in my sig to the UPDATED: ASP.Net Login Page, as it will give you code that is similar and may explain some things for you.
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- How To Create Login Page in ASP.NET (ASP.NET)
- Validating radio button selection for login redirect (JavaScript / DHTML / AJAX)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Help: How to validate a string in datagrid while edit mode
- Next Thread: J2EE or .NET
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects opera order problem ratings redirect registration relationaldatabases rotatepage search security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopemnt webdevelopment xml xsl






