Click here to Skip to main content
15,919,613 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Please Help: Javascript Error: Object doesn't support this property or method. Pin
Irshad Ahmed4-Jul-07 4:59
Irshad Ahmed4-Jul-07 4:59 
Questioncast in generics List of objects Pin
papy-boom4-Jul-07 0:07
papy-boom4-Jul-07 0:07 
AnswerRe: cast in generics List of objects Pin
Pete O'Hanlon4-Jul-07 0:28
mvePete O'Hanlon4-Jul-07 0:28 
QuestionRusty Coder Needs Help Pin
munklefish4-Jul-07 0:06
munklefish4-Jul-07 0:06 
AnswerRe: Rusty Coder Needs Help Pin
Urs Enzler4-Jul-07 0:22
Urs Enzler4-Jul-07 0:22 
GeneralRe: Rusty Coder Needs Help Pin
munklefish4-Jul-07 0:31
munklefish4-Jul-07 0:31 
Questionform authentication Pin
24891284-Jul-07 0:05
24891284-Jul-07 0:05 
QuestionProblem with SqlDataReader Pin
netwizerd4-Jul-07 0:01
netwizerd4-Jul-07 0:01 
I am building an ASP.Net C# Web project. in the HTML form of the .aspx file
I have

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

SqlConnection conn = new SqlConnection("Data Source=DATA-SERVER;Initial Catalog=Intech;Trusted_Connection=true");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM users WHERE username='"+Username.Value+"' AND password= '"+Password.Value+"'";

// Fill our parameters
cmd.Parameters.Add("@username", SqlDbType.NVarChar, 64).Value = Username.Value;
cmd.Parameters.Add("@password", SqlDbType.NVarChar, 128).Value = Password.Value; // Or "sha1"

// Execute the command
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
// Create a new ticket used for authentication
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // Ticket version
Username.Value, // Username associated with ticket
DateTime.Now, // Date/time issued
DateTime.Now.AddMinutes(30), // Date/time to expire
true, // "true" for a persistent user cookie
reader.GetString(0), // User-data, in this case the roles
FormsAuthentication.FormsCookiePath);// Path cookie valid for

// Encrypt the cookie using the machine key for secure transport
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName, // Name of auth cookie
hash); // Hashed ticket

// Set the cookie's expiration time to the tickets expiration time
if (ticket.IsPersistent) cookie.Expires = ticket.Expiration;

// Add the cookie to the list for outgoing response
Response.Cookies.Add(cookie);

// Redirect to requested URL, or homepage if no previous page
// requested
string returnUrl = Request.QueryString["ReturnUrl"];
if (returnUrl == null) returnUrl = "/";

// Don't call FormsAuthentication.RedirectFromLoginPage since it
// could
// replace the authentication ticket (cookie) we just added
Response.Redirect(returnUrl);
}

I have the table as

CREATE TABLE users
(
username nvarchar(64) CONSTRAINT users_PK PRIMARY KEY,
password nvarchar(128),
roles nvarchar(64)
)

CREATE INDEX credentials ON users
(
username,
password
)

Now I am trying to access the table but at

SqlDataReader reader = cmd.ExecuteReader();
reader.Read();

I am not getting any result from reader.Read();

I need help.
AnswerRe: Problem with SqlDataReader Pin
Colin Angus Mackay4-Jul-07 0:09
Colin Angus Mackay4-Jul-07 0:09 
GeneralRe: Problem with SqlDataReader Pin
netwizerd4-Jul-07 2:50
netwizerd4-Jul-07 2:50 
GeneralRe: Problem with SqlDataReader Pin
Colin Angus Mackay4-Jul-07 3:17
Colin Angus Mackay4-Jul-07 3:17 
GeneralI give up! Pin
Colin Angus Mackay4-Jul-07 3:11
Colin Angus Mackay4-Jul-07 3:11 
GeneralRe: I give up! Pin
Pete O'Hanlon4-Jul-07 3:16
mvePete O'Hanlon4-Jul-07 3:16 
GeneralRe: I give up! Pin
Colin Angus Mackay4-Jul-07 3:25
Colin Angus Mackay4-Jul-07 3:25 
GeneralRe: I give up! Pin
Pete O'Hanlon4-Jul-07 3:38
mvePete O'Hanlon4-Jul-07 3:38 
GeneralRe: I give up! Pin
Pete O'Hanlon4-Jul-07 3:54
mvePete O'Hanlon4-Jul-07 3:54 
GeneralRe: I give up! Pin
Colin Angus Mackay4-Jul-07 4:15
Colin Angus Mackay4-Jul-07 4:15 
GeneralRe: I give up! Pin
Pete O'Hanlon4-Jul-07 5:02
mvePete O'Hanlon4-Jul-07 5:02 
Questionhighlighting search terms Pin
marky7773-Jul-07 23:44
marky7773-Jul-07 23:44 
AnswerRe: highlighting search terms Pin
Pete O'Hanlon3-Jul-07 23:47
mvePete O'Hanlon3-Jul-07 23:47 
AnswerRe: highlighting search terms Pin
Pete O'Hanlon3-Jul-07 23:57
mvePete O'Hanlon3-Jul-07 23:57 
GeneralRe: highlighting search terms Pin
marky7774-Jul-07 0:10
marky7774-Jul-07 0:10 
QuestionGridview - dynamically added checkbox fields are Disabled Pin
Mohamed El Gohary3-Jul-07 23:39
Mohamed El Gohary3-Jul-07 23:39 
QuestionBinding Radio Button Control in GridView Pin
Ajeet mittal3-Jul-07 23:36
Ajeet mittal3-Jul-07 23:36 
Question'Sys' is undefined Pin
Abubakarsb3-Jul-07 23:23
Abubakarsb3-Jul-07 23:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.