Click here to Skip to main content
15,878,748 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

Might I ask some advice/fixes on the below code, as I am still not familiar with referencing multiple columns from DataTable in c++ yet? Confused | Confused | :confused: Your inputs would be much appreciated. Thanks in advance.

MySqlCommand^CmdDataBase = gcnew MySqlCommand("select * from world.city",conDataBase);
				 try{
					 conDataBase->Open();
					 MySqlDataAdapter^sda= gcnew MySqlDataAdapter();
					 sda->SelectCommand=CmdDataBase;
					 DataTable^dbdataset=gcnew DataTable();
					 DataColumn^rt_col=gcnew DataColumn();
					 rt_col->ColumnName = "Ret";
					 rt_col->DataType=System::Type::GetType("System.Double");
					 dbdataset->Columns->Add(rt_col);
 
 
					 DataRow^rt_row;
					 
					 for (int row=0;dbdataset->Rows->Count;row++)				 
					 {
						 rt_row=dbdataset->NewRow();
						 rt_row["Ret"]=System::Convert::ToDouble(rt_row["Population"])/System::Convert::ToDouble(rt_row["Population"]);
					     //rt_row["DataReturn"]=System::Convert::ToDouble(dbdataset->Rows[row]["Population"])/System::Convert::ToDouble(dbdataset->Rows[row-1]["Population"]);
						 dbdataset->Rows->Add(rt_row);
						 
					 }
					 
					 sda->Fill(dbdataset);	
					 BindingSource^bSource=gcnew BindingSource();
					 bSource->DataSource=dbdataset;
					 dtGrid->DataSource=bSource;
				 
				 } 
				 catch(Exception^ex) {
					 MessageBox::Show(ex->Message);
		 }
Posted
Updated 23-Nov-14 21:33pm
v2

1 solution

Please do not multipost. You already asked this in the C++ forum.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900