View Single Post
  #3 (permalink)  
Old March 2nd, 2009, 02:34 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

Hi this is the code:
Code:
protectedvoid Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlDataReader MyReader;
SqlConnection MyConnection = newSqlConnection();
MyConnection.ConnectionString =
ConfigurationManager.ConnectionStrings["Minds"].ConnectionString;
SqlCommand MyCommand = newSqlCommand();
MyCommand.CommandText = "SELECT HomeLeft FROM Home";
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = MyConnection;
MyCommand.Connection.Open();
MyReader = MyCommand.ExecuteReader(CommandBehavior.CloseConnection);
  //this.Label1.DataSource = MyReader;
  //thisLabel1.DataBind();
MyCommand.Dispose();
MyConnection.Dispose();
 
}
}
if i use a listbox or gridview it works but i want to use a label,

this is what i have in vb 2.0
Code:
Dim con AsNew SqlConnection(ConfigurationManager.ConnectionStrings("test").ConnectionString)
Dim cmdd AsNew SqlCommand("select NumberEmailSent from AsigntUsers Where Name= @Name")
Dim dr As SqlDataReader = Nothing
cmdd.Parameters.Add("@Name", Data.SqlDbType.NVarChar, 50).Value = Me.lblUser.Text
cmdd.Connection = con
con.Open()
dr = cmdd.ExecuteReader()
dr.Read()
If dr.HasRows() = TrueThen
Me.sent.Text = dr("NumberEmailSent").ToString
EndIf
con.Close()
__________________
bx