Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>try this.</p> <p>Please note : that if your sproc returns more than one row it will take the last one only. because you are looping through an object only. if you are expecting more result than you should use List or somekind a collection object.</p> <pre><code> public partial class Admin : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet("ot_Users"); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) { using (SqlCommand command = conn.CreateCommand()) { command.CommandText = "dbo.ot_User_GetByUserName"; command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@UserName", Environment.UserName); conn.Open(); SqlDataReader reader = command.ExecuteReader(); ot_Users user = new ot_Users(); while(reader.Read()) { user.CompanyId = reader["CompanyId"] != DBNull.Value ? (int)reader["CompanyId"] : 0 ; user.UserId = reader["UserId"] != DBNull.Value ? (int)reader["UserId"] : 0 ; user.FirstName = reader["FirstName"] != DBNull.Value ? reader["FirstName"].ToString() : string.Empty; user.LastName = reader["LastName"] != DBNull.Value ? reader["LastName"].ToString() : string.Empty; user.CompanyAdmin = reader["CompanyAdmin"] != DBNull.Value ? (bool)reader["CompanyAdmin"] : false ; user.AccountStatus = reader["AccountStatus"] != DBNull.Value ? (int)reader["AccountStatus"] : 0 ; user.UserName = reader["UserName"] != DBNull.Value ? reader["UserName"].ToString() : string.Empty; } if (user != null) { CompanyName.Text = user.FirstName.ToString(); } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload