Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@funmonster-x0ZBEH • Jan 21, 2010
prabhat kumarhi 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-x0ZBEH • Jan 27, 2010
HurstWhen 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|\<your database name>.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-KhhWSv • Jan 29, 2010
thanks every one i got my solution...
-
@funmonster-x0ZBEH • Jan 30, 2010
prabhat kumarthanks every one i got my solution...
Please choose best solution or post it so that it may help some one in future..