Hi my Friends,
I dont know what is the problem in my code, Could somebody help me please??
===
this is the page:
===
=============== ==========
=============== =========
this is the C# code for this page
=========
=============== =========
the problem is in the
"Line 22: SqlDataReader reader = cmd.ExecuteRead er();"
???
Every thing else is OK regarding the Database. I created a table in the database with Mouza as username & 123457 as password.
Could somebody help me here... please...
I dont know what is the problem in my code, Could somebody help me please??
===
this is the page:
===
Code:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div align="left" style="text-align: center">
<table style="z-index: 102; left: 290px; position: absolute; top: 50px">
<tr>
<td align="center" style="width: 438px; height: 14px" valign="middle">
</td>
</tr>
<tr>
<td align="left" style="width: 438px" valign="middle">
<table align="center">
<tr>
<td style="font-weight: bold; width: 265px">
Please login to access the Website<br />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" style="width: 438px" valign="middle">
<table align="center">
<tr>
<td style="width: 77px; height: 26px">
<asp:Label ID="Label1" runat="server" Text="User Name:"></asp:Label></td>
<td style="width: 191px; height: 26px">
<asp:TextBox ID="userName" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 77px">
<asp:Label ID="Label2" runat="server" Text="Password: "></asp:Label></td>
<td style="width: 191px">
<asp:TextBox ID="passWord" runat="server" TextMode="Password"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 77px">
</td>
<td style="width: 191px">
</td>
</tr>
<tr>
<td style="width: 77px">
</td>
<td style="width: 191px">
<asp:Button ID="submit" runat="server" OnClick="submit_Click" Text="Submit" /></td>
</tr>
</table>
</td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</asp:Content>
=============== =========
this is the C# code for this page
=========
Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
public void checkUser(String username, String password)
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionToEL"].ConnectionString);
cmd.CommandText = @"select * from " ;
cmd.Connection.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string name = reader[0].ToString();
string pass = reader[1].ToString();
if ((name.Equals(username)) && (pass.Equals(password)))
{
Response.Redirect( "StudentHome.aspx");
}
}
reader.Close();
cmd.Connection.Close();
}
Response.Redirect("Default.aspx");
}
protected void submit_Click(object sender, EventArgs e)
{
String n = this.userName.Text;
String p = this.passWord.Text;
checkUser(n, p);
}
}
the problem is in the
"Line 22: SqlDataReader reader = cmd.ExecuteRead er();"
???
Every thing else is OK regarding the Database. I created a table in the database with Mouza as username & 123457 as password.
Could somebody help me here... please...
Comment