better solution?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zarish

    #1

    better solution?

    hi,
    im using a disconnected recordset feature of ado.net in my webservice and
    pasing it to my application.

    [WebMethod]
    public DataSet getAllCarTypes( )
    {
    string sqlQuery = "select distinct(descri ption) from cars";
    SqlDataAdapter da = new SqlDataAdapter (sqlQuery,conn) ;
    DataSet ds = new DataSet();
    da.Fill (ds,"Cars");
    return ds;
    }



    private void Form1_Load(obje ct sender, System.EventArg s e)
    {
    string delimStr = ",";
    char [] delimiter = delimStr.ToChar Array();
    string [] split = null;
    ser=new Service1();
    ds=ser.getAllCa rTypes();
    String data=PrintRows( ds,"description ");
    cmbType.Items.C lear();
    split = data.Split(deli miter);
    foreach (string s in split)
    {
    if (s!="")
    cmbType.Items.A dd(s);
    }
    cmbType.Selecte dIndex=0;
    }

    here i am trying to get the description column only from the dataset.
    i feel this approach is a very long one.. can anyone suggest a shorter
    approach?

    thanx

    Zarish




Working...