mysql查询数据导入到数组中,如何将数据库查询结果添加到数组

本文展示了如何从数据库查询中获取数据并将其存储到数组或列表中。建议使用List(Of String)而非字符串数组,以利用其灵活性。提供了一个公共函数作为示例,演示了如何将查询结果转换为List并返回,以及如何消费这个函数来打印列表或数组内容。
摘要由CSDN通过智能技术生成

I am trying to select string values from an Access database and then place them into an array of strings so that I can perform a loop statement on the array.

However I don't know how to place the result of the query into an array. I know how to query the database but all I need is how to put the result in an array.

My select statement is Select motonum from moto. I want to put motonum in an array.

The whole code to read the data is:

connect2()

If Not cnn2.State = ConnectionState.Open Then

'open connection

cnn2.Open()

'MessageBox.Show("chk2")

End If

cmd5.Connection = cnn2

cmd5.CommandText = "Select motonum from moto"

myData5 = cmd5.ExecuteReader

While myData5.Read

'code to return results here

End While`

解决方案

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值