100 free .NET Tutorial Videos from Beginner to Expert | aspv.cooltuts.com If you like this site, Tell your friends and leave your feedback to encourage me to add more videos

Create a Login Form in ASP Net

[postlink]http://aspv.cooltuts.com/2010/04/create-login-form-in-asp-net.html[/postlink]http://www.youtube.com/watch?v=QWa_FPIM2Awendofvid

27 comments:

naina said...

Error occure at this line
dr = cmd.ExecuteReader()
'''
Imports System.Data.SqlClient

Partial Public Class Staff
Inherits System.Web.UI.Page
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim dr As SqlDataReader

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
con = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=D:\khan\khan's work\Visual studio\Vote Casting\CastVote\CastVote\App_Data\Database1.mdf;Integrated Security=True;User Instance=True")

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
con.Open()
cmd = New SqlCommand("select paswrd from login where username=textbox1.text", con)
dr = cmd.ExecuteReader()

If (dr(0).ToString() = TextBox2.Text) Then
Response.Redirect("about.aspx")
Else
Response.Write("Wrong")
End If
,,,
Emmu can u make this program again in vb.

naina said...

i also write shared dr As SqlDataReader
but error again

emmu said...

try after
removing brackets
dr = cmd.ExecuteReader

naina said...

again error..

emmu said...

Sure i will make a video on LOGIN in ASP(vb)

Anonymous said...

great work man..i just would like to know how do we authorize roles for users after login

Anonymous said...

i made connection between both my asp page and sql server..but when i execute it shows an error on the term "con.open"..plz give me the solution.

emmaneale said...

Can you paste your code here

pinky said...

i have one problem actually i make a project in .net n i have one problem in my project a data entry from is present so many enteries like sender and receiver detail is present them my form is not look well so i want user fill this entry in step but data save in same table then plz tell me solution of my problem

emmu said...

you can use sessions to store values on one page and insert all values at one page.... if i got time i vll show you through a video

Thanks

Archita said...

i have a one problem in my project display table data in form using gridview but in
table countryid are stored i want to display a country name in grid
view and that country name stored in xml file then how to fetch the
country name in xml file plz give me solution through video

emmu said...

Hi Archita i already shown you how to display table in gridview when it is in XML

http://learn-aspdotnet.blogspot.com/2010/06/display-xml-file-data-in-gridview.html

Copy this link.. and let me know it is helpful to you...

Anonymous said...

hai emmu..i am ram from chennai..im doins a 'project online movie ticket booking'..i need a code and method for seat selection..im doing it asp.net with c# code..can u plz help me..

shahina said...

Thanks a lot..I have learnt a lot from ur tutorials..very useful..I have a request..Please put a tutorial on login using salted has algorithm and user roles..May God Bless you..

Paul said...

I have followed your tutorial but I can not login with the correction login details. Wrong password error shows all the time. Can you help?

My code is below, I can't see any difference between your code and mine!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Documents\\Visual Studio 2010\\WebSites\\forum\\App_Data\\forum.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd;
SqlDataReader dataReader;

protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
cmd = new SqlCommand("SELECT Password FROM members WHERE Username='" + txtUsername.Text + "'", con);
dataReader = cmd.ExecuteReader();
if (!dataReader.Read())
{
Response.Write("Wrong Details");
}
else
{
if (dataReader[0].ToString() == txtPassword.Text)
Response.Redirect("index.aspx");
else
Response.Write("Wrong Password");
}

}
}

emmu said...

Is should work Paul check your Database Values?

Anonymous said...

please upload floatbox example in asp.net (c#)
Thank u................
ur videos help us alot
thanks again........

harish said...

Hi Emmu,
can u plsz help me to find wats wrong with the code......
SqlConnection con = new SqlConnection(@"Data Source=HARISHPRAVEEN\SQLEXPRESS;Initial Catalog=flavourzsfoods;Integrated Security=True");
SqlCommand cmd;
SqlDataReader dr =null;


protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
cmd = new SqlCommand("SELECT * FROM login WHERE username= '" + TextBox1 + "'", con);
dr = cmd.ExecuteReader();
if (!dr.Read())
{
Label1.Text = "Wrong detials";

}
else
{
if (dr[0].ToString() == TextBox2.Text)
Response.Redirect("makeorder.aspx");
else
Label1.Text = "Wrong detials";

}
}

harish said...

hi emmu,
i posted the above comment....
Even i enter the correct details it shows as "wrong detail ".......
plsz help me

aa said...

hi emmu,

i am following you from last two months. i have learned a lot but i have a small problem i am not getting the sql server 2008 browser. i have configuration tools as configuration manager,installation tools but i am not getting web browser can you please let me how to get the browser

Anonymous said...

SqlConnection con = new SqlConnection("Data Source=AFVAN;Initial Catalog=login;Integrated Security=True");
SqlCommand cmd;
SqlDataReader dr;
protected void LinkButton1_Click(object sender, EventArgs e)
{
string un = "";
un=TextBox1.Text;
con.Open();
Response.Write("connected");
cmd = new SqlCommand("select * from login where username='un'",con);
dr=cmd.ExecuteReader();//error here that the connection property is not initialised
if (dr.Read())
{
Label1.Text = "USERNAME AVAILABLE";

}
else
{
Label1.Text = "NOT AVAILABLE";
}

zakirughradar said...

hi all my dear frnds :::

button coding::

con.open();
sqldata adapter da = new data adapter();
sql command com =new sql command("select username,password from (your data table name put here),"con);

plz try this coding sure you will sucesse...

if you know more about plz contect me :91 9898370946.....zakir from india....

zakirughradar said...

zakir ughradar :::
plz try this code:::

con.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select username,password from log", con);
da.Fill(ds);

if (TextBox1.Text != "" && TextBox2.Text != "")

{
for (int i=0; i<ds.Tables[0].Rows.Count; i++)
}

String s =ds.Tables[0].Rows [i][0].ToString();
int j=1;
String p =ds.Tables[0].Rows [i][j].ToString();
if (TextBox1.Text == && TextBox2.Text==p)
{
Label3.Text="login sucsessfully";
}


{
Label3.Text="invalid login";
}

Anonymous said...

Hi sir, i understood this one but now i am doing one thing in that i used two button for login and signup respectively but problem is i need to get login page in home page when i click on login button and simillar way i need to get signup page also instead of navigate to other page..
thaks

mendu said...

Then use a ajax modal popup for login and signup.

Anonymous said...

hello sir,it still taking names by the same name how can write code for that. you have given only for checking for availbility

sim said...

hi.. plz tell me what is wrong with this code..build succesfully, but after that got the error connection property is not initialized... plz chk this code

SqlConnection cn = new SqlConnection(@"Data Source=SIM-PC\SQLEXPRESS;AttachDbFilename=C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\DB\\HBA.mdf;Database=HBA;Integrated Security=True");
cn.Open();
}

public void DBCMDExcute(string query)
{
DBOpen();
cmd = new SqlCommand(query, cn);
cmd.ExecuteNonQuery();
}

public void DBReader(string query)
{
DBOpen();
cmd = new SqlCommand(query, cn);
dr = cmd.ExecuteReader();
dr.Read();

}
public void DBReaderClose()
{
cn.Close();
cmd = null;
dr.Close();
}
public void DBCMDClose()
{
cn.Close();
cmd = null;
}

}
}

Post a Comment

Followers

There was an error in this gadget