Use the DataTable.Columns.Count property. So ds.Tables[0].Columns.Count
.
If you have a DataRow
you can also use this property via...
int columnCount = row.Table.Columns.Count;
or another option is the DataRow.ItemArray
which contains all fields:
int columnCount = row.ItemArray.Length;