SqlCommand asp.net C#

Posted by emilios on Stack Overflow See other posts from Stack Overflow or by emilios
Published on 2011-06-23T23:27:32Z Indexed on 2011/06/24 0:23 UTC
Read the original article Hit count: 341

Filed under:
|
|

i you please help me out with my problem i am trying to create a function that output the data on a dropdownlist an setting my parameters my code goes as follow :

        public static List<string> GetTracks(out List<string> trackIds, string conferenceId)
    {

        var res = new List<string>();
        trackIds = new List<string>();
        var sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        SqlCommand cmd = new SqlCommand("select Track_name,Track_ID from TrackCommittee where Conference_id= @conferenceId", sqlCon);
        DataSet ds = new DataSet();
        cmd.Connection.Open();
        cmd.Parameters.Add(new SqlParameter("@conferenceId", conferenceId));



        using (SqlDataReader sdr = cmd.ExecuteReader())
        {
       while (sdr.Read())
       {
        res.Add(sdr.GetString(sdr.GetOrdinal("Track_name")));
        trackIds.Add(sdr.GetInt32(sdr.GetOrdinal("Track_ID")).ToString());
       }
               }


        cmd.Connection.Close();
        cmd.Dispose();
        return res;
    }

thanking you in advance

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET