如何在c语言中将sql server数据库记录插入数组
我想在c中的数据库上执行kmeans集群。为此,我需要将整个数据库放在多维数组中 我用以下方式创建了连接如何在c语言中将sql server数据库记录插入数组,c,sql-server,arrays,C,Sql Server,Arrays,我想在c中的数据库上执行kmeans集群。为此,我需要将整个数据库放在多维数组中 我用以下方式创建了连接 mySQLConnection = gcnew SqlConnection("Data Source=komal-pc;Initial Catalog=data;Integrated Security=True"); mySQL = gcnew SqlCommand ("select * from datatb", mySQLConnection); mySQLCo
mySQLConnection = gcnew SqlConnection("Data Source=komal-pc;Initial Catalog=data;Integrated Security=True");
mySQL = gcnew SqlCommand ("select * from datatb", mySQLConnection);
mySQLConnection->Open (); // Open up the connection
myReader = mySQL->ExecuteReader ();
这是我迄今为止尝试过的代码:
c.while(myReader->Read()) {/* for(j=0;j<2;j++) {*/ array[i][0]= Convert::ToInt16 (myReader["id"]); array[i][1]= Convert::ToInt16 (myReader["age"]); } printf("%d", array[i][0]); printf("%d\n", array[i][1])
我能读懂全部数据。
请告诉我如何将数据放入数组这是什么语言?您尝试过什么吗?这是使用visual c fori=0完成的;iRead{array[i][0]=Convert::ToInt16 myReader[id];array[i][1]=Convert::ToInt16 myReader[age];}printf%d,array[i][0];printf%d\n,数组[i][1];但是,只有最后一个值存在于阵列中。在将来,请将代码放在您的问题中,而不是放在这里的注释中。这次我为您添加了它,但是您需要格式化它以使其可读。谢谢