C
Chris Taylor
Pleasure, hope you enjoy .NET and all it has to offer!
shahrukh said:excellent!!
thank you... i am (was?) a vb 6 programmer trying to migrate to dotnet..
where can i learn more on ado? i d like to specialize in ado and database
(after some years, that is)
thanx for your help works like a charm
Chris Taylor said:Hi,
You can enumerate the rows in the DataTable that is returned in the DataSet
ds=ser.getAllCarTypes();
foreach( DataRow dr in ds.Tables[0].Rows )
{
if ( !dr.IsNull(0) ) // Check that the column is not null
cmbType.Items.Add( dr[0] );
}
The above example uses 0 for the table and 0 for the column, this is based
on the sample you provided. In both cases you could also use the string name
for each as in ds.Tables["Table1"].Rows and dr["description"].
Hope this helps
Chris Taylor
Zarish said: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(description) from cars";
SqlDataAdapter da = new SqlDataAdapter (sqlQuery,conn);
DataSet ds = new DataSet();
da.Fill (ds,"Cars");
return ds;
}
private void Form1_Load(object sender, System.EventArgs e)
{
string delimStr = ",";
char [] delimiter = delimStr.ToCharArray();
string [] split = null;
ser=new Service1();
ds=ser.getAllCarTypes();
String data=PrintRows(ds,"description");
cmbType.Items.Clear();
split = data.Split(delimiter);
foreach (string s in split)
{
if (s!="")
cmbType.Items.Add(s);
}
cmbType.SelectedIndex=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