Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear friends

Can you pleae tell me how to fatch a recor in a text box from sql server in Descinding order on page load.....




thanks:
Posted

1 solution

Here is the sample code:
C#
public void load() 
{
    //Intializing sql statement
    string sqlStatement = "SELECT EmpName FROM Employee WHERE 
    EmpID=@EmployeeID ORDER BT EmpName DESC" ;

    SqlCommand comm = new SqlCommand();
    comm.CommandText = sqlStatement;
    int empID = int.Parse(Request.QueryString["EmployeeID"]);

    SqlConnection connection = Ideal_DataAccess.getConnection();
    comm.Connection = connection;

    comm.Parameters.AddWithValue("@EmployeeID", empID);

    try
    {
       connection.Open();
       comm.ExecuteNonQuery();
       txtBxName.Text= string.Format("<%# Bind(\"{0}\") %>", "EmpName");

    }
    catch (Exception ex)
    {
        throw ex;
    }
    finally
    {
        connection.Close();
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900