Israel

Israel

  • 705
  • 1.3k
  • 216.4k

The real name of my "username" should appear next

Jan 14 2014 7:43 AM

Hi!

My table have columns: "name", "username", "password", "email". I have these codes to log in my database. Its works well! What I need? When I log in with correct "username" and "password" I get in automatically on the next page called "visual.aspx" . But I want to see the real "name" I putted when I created the first time my "username" to appear on this page (visual.aspx) as a "label".
 

using System;

using System.Data;

using System.Data.SqlClient;

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;

public partial class Login : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void log_Click(object sender, EventArgs e)

{

SqlDataSource sds = new SqlDataSource();

sds.ConnectionString = ConfigurationManager.ConnectionStrings["master"].ToString();

sds.SelectParameters.Add("username", TypeCode.String, this.username.Text);

sds.SelectParameters.Add("password", TypeCode.String, this.password.Text);

sds.SelectCommand = "SELECT * FROM [myTb] WHERE [username] = @username AND [password] = @password";

DataView dv = (DataView)sds.Select(DataSourceSelectArguments.Empty);

try

{

if (dv.Count == 0)

{

this.lblinfo.ForeColor = System.Drawing.Color.Red;

this.lblinfo.Text = "Invalid username and password!";

return;

}

else

{

FormsAuthentication.RedirectFromLoginPage(username.Text, true);

Response.Redirect("~/English/Visual.aspx");

 
/////which kind of code can I write here/////// 

}

}

catch

{

}

finally

{

}

}

}