Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在c语言中将sql server数据库记录插入数组_C_Sql Server_Arrays - Fatal编程技术网

如何在c语言中将sql server数据库记录插入数组

如何在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

我想在c中的数据库上执行kmeans集群。为此,我需要将整个数据库放在多维数组中

我用以下方式创建了连接

    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];但是,只有最后一个值存在于阵列中。在将来,请将代码放在您的问题中,而不是放在这里的注释中。这次我为您添加了它,但是您需要格式化它以使其可读。谢谢