我如何将值从C#中的数据库存储到数组中 [英] how can i store the values into the array from the database in c#

查看:166
本文介绍了我如何将值从C#中的数据库存储到数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将数据库中的值存储到单个三维数组中,如何将其与db绑定.

i want to store the values from the database to single dimentional array how can i bind the array with db.

推荐答案


试试这个:
Hi,
Try this:
int count=0;
string[] userID;
SqlCommand cmdProc = new SqlCommand("SELECT UID FROM tbUserDtls", con);
SqlDataReader sda = com.ExecuteReader();
//Counting the rows
while(sda.Read())
{
    count++;
}
//setting the size of array
userID = new string[count]{};
count = 0;
while(sda.Read())
{
    count ++;
    userID[count] = sda[0].ToString();
}
//Now you have an array of userid



--Amit



--Amit


这篇关于我如何将值从C#中的数据库存储到数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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