如何在vb.net中将数据库查询结果添加到数组中... [英] how to add database query results to an array in vb.net ...
本文介绍了如何在vb.net中将数据库查询结果添加到数组中...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
我目前正在对我的数据库运行查询并尝试将查询结果放入数组但不确定如何执行此操作
这个我到目前为止的简短代码
Cmd =新的SqlCommand( 从Recordtype中选择*其中type ='A',con)
Dim reader As SqlDataReader = Cmd.ExecuteReader
如果 reader.HasRows 那么
读取器。读取()
请你帮助
解决方案
非常有趣的问题(投票5) !
我发现了2篇关于它的文章:
DataTable到C#中的字符串数组而不使用for循环 [ ^ ]
如何将IEnumerable转换为DataTable的方式与我们使用ToList或ToArray的方式相同 [ ^ ]
想象一下,编写将数据表转换为数组的代码是一个挑战!
hi
I am currently running a query to my database and trying to put the results of the query into an array but not sure how to do this
This brief code that i have thus far
Cmd = New SqlCommand("Select * from Recordtype where type = 'A'", con)
Dim reader As SqlDataReader = Cmd.ExecuteReader
If reader.HasRows Then
While reader.Read()
Please could you assist
解决方案
Very interesting question (voted 5)!
I found 2 articles about it:
DataTable To String Array in C# without using a for Loop [^]
How to convert an IEnumerable to a DataTable in the same way as we use ToList or ToArray[^]
Imagine, it's a challenge to write the code to convert datatable to array!
这篇关于如何在vb.net中将数据库查询结果添加到数组中...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文