将SQL结果存储在2D数组中? [英] Store SQL result in a 2D array?

查看:46
本文介绍了将SQL结果存储在2D数组中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想知道如何将SQL结果存储到2d数组中.

SQL结果是13 x 25的表.因为我希望对结果表中的每个元素进行计算,所以我希望每个元素都是一个变量(因此,二维数组似乎是最好的解决方案).

我只是不确定如何将SQL查询结果写入2D数组.

请帮忙.

Nicole

Hi guys,

I would like to know how to store a SQL result into an 2d array.

The SQL result is a 13 x 25 table. Because i wish to do calcuations with each element in this result table, i would like each element to be a variable (hence a 2d a array seemed like the best solution).

Im just not sure how to write the SQL query result into a 2D Array.

Please help.

Nicole

推荐答案

如果将结果返回到DataTable中,则它已经存在于2D数组中:向下排,每个单元格之间都有单元格.
If you return the result into a DataTable, it is already in a 2D array: Row downward, each having Cells across.


使用锯齿形阵列 [ ^ ]来存储和然后根据需要进行计算.

样本:
Use Jagged Array[^] to store and then do calculations as you wish.

Sample:
int[][] sqlResult = new int[13][];
for (int x = 0; x < 12; x++)
{
   sqlResult[x] = new int[25];
}


阅读 ^ ]有关sql中动态透视的文章
read my[^] article about dynamic pivotting in sql


这篇关于将SQL结果存储在2D数组中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆