Link to home
Start Free TrialLog in
Avatar of FrancineTaylor
FrancineTaylor

asked on

"Cannot implicitly convert type 'object' to 'System.Data.DataColumn'


This is the code:

      DataSet ds = GetDataSet(psTable, psSQL);
      DataColumn dc = ds.Tables[0].Rows[0][piColumn];

The second line gives the error in the title.  I'm converting my code from VB.NET to C#.NET and I'm obviously not getting the syntax quite right.
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Hello FrancineTaylor,

you could try something like
--------------
DataColumn dc = New DataColumn[] {ds.Tables[0].Columns["piColumn"]};
--------------

hope this helps a bit
bruintje

ds.Tables[0].Rows[0][piColumn]; => Returns the data as thr 0th row of the piColumn as object.
If you want to get the datacolumn you should use
   ds.Tables[0].Columns[0]
the problem is not casting problem. More than it.
ASKER CERTIFIED SOLUTION
Avatar of Yurich
Yurich
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial