if u are making login page so u need to check whether user has an account, u can achieve this by simple aspx design and simple stored procedure following is the complete code.....
In .aspx copy paste the following
<body>
<form id="form1" runat="server">
<div>
<br />
<table>
<tr>
<td style="width: 148px">
name</td>
<td style="width: 150px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 148px">
password</td>
<td style="width: 150px">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 148px; height: 6px;">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></td>
<td style="width: 150px; height: 6px;">
<asp:Label ID="Label1" runat="server"></asp:Label><p class="MsoNormal" style="margin: 0in 0in 10pt">
<span style="font-size: 11pt; font-family: 'Arial Unicode MS','sans-serif'; mso-fareast-font-family: 'Times New Roman';
mso-fareast-theme-font: minor-fareast"></span>
</p>
</td>
</tr>
</table>
</div>
</form>
</body>
-------------------------------
following is code for .aspx.cs, as i have used separate class for connection strings u can change accordng
using System.Drawing;
protected void Button1_Click(object sender, EventArgs e)
{
dbclass.mycon();
SqlCommand cmd = new SqlCommand("memberlogin", dbclass .con);
cmd.CommandType =CommandType.StoredProcedure;
cmd.Parameters.Add("@name", SqlDbType.VarChar).Value = TextBox1.Text;
cmd.Parameters.Add("@password", SqlDbType.Int).Value = TextBox2.Text;
SqlDataReader rd = cmd.ExecuteReader();
if (rd.HasRows)
{
Label1.ForeColor = Color.Green;
Label1.Text="login successfuly,user found";
}
else
{
Label1.ForeColor = Color.Red;
Label1.Text = "user not found";
}
}
--------------
then make the table in sqlserver
CREATE TABLE [dbo].[stuloginstoreproc]
(
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) NULL,
[password] [int] NULL,
)
----------------------
following is the simple stored procedure in programmability section of sql server database
create PROCEDURE [dbo].[memberlogin]
@name varchar(50),
@password int
AS
BEGIN
SET NOCOUNT ON;
SELECT * from stuloginstoreproc where name=@name and password=@password
END
its done, if u need further help u can ask me
mark if this helps u
ankit saxena
Krishnamanohar, if this helps please login to Mark As Answer. | Alert Moderator