Results 1 to 13 of 13

Thread: Return datarow objs ?[Resolved by Edneeis]

Threaded View

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Talking Return datarow objs ?[Resolved by Edneeis]

    This works fine but I rather prefer to return datarow obj instead of binding to combobox (for code reusability) , so that I can use it like this

    comboBox1.Items.Add(PopulateMainCat("mytable"));

    Code:
    public object PopulateMainCat(string MainTableCat)
    {
    OpenDB();
    DataSet ds =new DataSet();
    string sqlstr ="SELECT * FROM " + MainTableCat + "";	
    OleDbDataAdapter adp =new OleDb.OleDbDataAdapter(sqlstr,MyConnection);
    
    adp.Fill(ds,MainTableCat);
    foreach(DataRow dr in ds.Tables[MainTableCat].Rows)
    {
    //I don't want this 
    comboBox1.Items.Add(dr[1]);
    //but I would love this way 
    //return dr[1];
    }
    DBSpace.CloseDB.CloseDB1();
    }
    Thanks for having a look .
    Last edited by Pirate; Jun 27th, 2003 at 10:49 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width