Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

User name is not displayed in the output in listbox

$
0
0

hi

i want show output this code in list box

    protected void Page_Load(object sender, EventArgs e)
    {
        Session["userName"] = User.Identity.Name;
        Label1.Text = Session["userName"].ToString();


        SqlConnection connect = new SqlConnection();
        connect.ConnectionString = "Data Source=.;Initial Catalog=AspNetSqlProvider;Integrated Security=True";
        string q = string.Format("select UserName from aspnet_Users where UserId in(select FreindId from myFreinds where UserId in(select UserId from aspnet_Users where UserName = '{0}'))", Label1.Text);
        SqlCommand cmd = new SqlCommand(q, connect);
        cmd.Connection.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        ListBox1.DataSource = dr;
        ListBox1.DataBind();
        cmd.Connection.Close();
}

The output should be as follows for example:

susan

david

ali

but is:

http://social.msdn.microsoft.com/Forums/getfile/467340

how to fix it.thanks


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>