Converting a DataSet to collection
-
Monday, July 11, 2011 2:19 PM
Hi all,
i am a new intern and i am having some trouble creating a JIT pivotviewer. Right now i have a dataset filled with data but i cannot figure out how to get the dataset to work with the foreach to add the data to different facets. I am using just a sql string with oraclecommand. I will post my code here:
namespace PivotServerTools{public class CollectionFactoryBase{private OracleConnection conn = new OracleConnection();private OracleCommand cmd;private OracleDataAdapter da;private OracleCommandBuilder cb;private DataSet ds;public override Collection MakeCollection(CollectionRequestContext context){conn.ConnectionString = "User Id=a501300;Password=;Data Source=SAQ1C;";try{const int maxItems_c = 150;conn.Open();string sql = "select insert_id, sai_id, Long_name, Short_name from sa_instrument_basic where rownum <50";conn.Close();Collection collection = new Collection();collection.Name = "learnDB collection";cmd = new OracleCommand(sql, conn);cmd.CommandType = CommandType.Text;da.TableMappings.Add("Table","sa_instrument_basic");da = new OracleDataAdapter(cmd);cb = new OracleCommandBuilder(da);ds = new DataSet();da.Fill(ds);}catch (OracleException ex){throw(ex);}}}}
namespace PivotServerTools
{
public class CollectionFactoryBase
{
private OracleConnection conn = new OracleConnection();
private OracleCommand cmd;
private OracleDataAdapter da;
private OracleCommandBuilder cb;
private DataSet ds;
public override Collection MakeCollection(CollectionRequestContext context)
{
conn.ConnectionString = "connection";
try
{
const int maxItems_c = 150;
conn.Open();
string sql = "querystring";
conn.Close();
Collection collection = new Collection();
collection.Name = "learnDB collection";
cmd = new OracleCommand(sql, conn);
cmd.CommandType = CommandType.Text;
da.TableMappings.Add("Table","table");
da = new OracleDataAdapter(cmd);
cb = new OracleCommandBuilder(da);
ds = new DataSet();
da.Fill(ds);
}
catch (OracleException ex)
{
throw(ex);
}
}
}
}
i need to take the data in the dataset and convert it into something that the collection.additem can use.
any suggestions are helpfull. thank you in advance - will
All Replies
-
Monday, July 11, 2011 5:17 PM
One option you have to is to loop through and create a list by help of DataReader,
please check this linkshttp://forums.silverlight.net/forums/p/199875/480283.aspx
http://social.msdn.microsoft.com/forums/en-US/adodotnetdataproviders/thread/5b1c29e2-bf37-4dd2-be39-50d27abb188e
http://www.c-sharpcorner.com/UploadFile/anavijai/4431/ -
Tuesday, July 12, 2011 11:16 AM
thanks for the help. I know how to turn the data into a list but that is only half of what i need. I need the data to then be added to a pivotviewer collection using collection.additem(string, sringurl, ,image...)
i was thinking of using another loop through but im not sure how to do this.
ps. please move all comments to my other thread, for some reason the forum created two seperate threads at the same time.
-
Monday, July 18, 2011 2:34 PM
Hi willax223,
Seems you continue this discussion at a duplicate post at
http://betaforums.silverlight.net/t/233950.aspx/1/10
So this one is closed.
Best Regards,

