1. Home >
  2. Apps >
  3. Groups >

problem on asp.net

Question asked by prabhat kumar in #Coffee Room on Jan 18, 2010
prabhat kumar
prabhat kumar · Jan 18, 2010
Rank D2 - MASTER
hi everyone,presently i m working in asp.net.i want to retrive data like move
first last add jst like in a form,i have already done gridview list view and form view,if here anybody have done this type of coding then say me is it possible?
if yes then how? Posted in: #Coffee Room
funmonster
funmonster · Jan 21, 2010
Rank E1 - BEGINNER
prabhat kumar
hi everyone,presently i m working in asp.net.i want to retrive data like move
first last add jst like in a form,i have already done gridview list view and form view,if here anybody have done this type of coding then say me is it possible?
if yes then how?
Dude! I'm familiar with ASP.NET, but I didn't understand what you say. If you can elaborate I may help you.
funmonster
funmonster · Jan 27, 2010
Rank E1 - BEGINNER
Hurst
When I write code in ASP.NET to access the database...what can I do to avoid thisproblem. to the database server else there is a problem with username and password if the connection.
Make sure the database connection is open till you your query is completely executed, As in the following example:

public partial class Login : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\.mdf;Integrated Security=True;User Instance=True");

protected void Button1_Click(object sender, EventArgs e)
{
String qry = "select username,password from registration where username=@username and password=@password";
SqlCommand cmd = new SqlCommand(qry, con);
cmd.Parameters.Add("@username", SqlDbType.VarChar, 40).Value = UserName.Text;
cmd.Parameters.Add("@password", SqlDbType.VarChar, 40).Value = Password.Text;
con.Open();
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["uname"] = UserName.Text; //UserName is the ID of the text box field
Response.Redirect("SuccessfulLogin.aspx"); //Direct the control to user profile
}
else
{
Response.Redirect("Loginfailure.aspx"); //Direct the control to login failure page
}
con.Close();
}
}
prabhat kumar
prabhat kumar · Jan 29, 2010
Rank D2 - MASTER
thanks every one i got my solution...
funmonster
funmonster · Jan 30, 2010
Rank E1 - BEGINNER
prabhat kumar
thanks every one i got my solution...
Please choose best solution or post it so that it may help some one in future..

You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up