如何实现数据库查询后定义成数组

如何实现数据库查询后定义成数组,第1张

我这代码是用vbs写的

set db = CreateObject("ADODB.Connection")

db.Open("...")

sql = "select * from chacha where id=2"

set rs = db.Execute(sql)

row = 1

lie = ""

zhi = ""

shu = ""

do until rs.EOF

for x = 1 to rs.fields.count ' 或者直接写 to 8

waValue = rs("wa" &x)

if waValue != 0 then ' 如果数据类型是字符串,就把0改为"0"

lie = lie &row &","

zhi = zhi &waValue &","

shu = shu &x &","

next

rs.MoveNext

row = row + 1

loop

lie = left(len(lie)-1) ' 去掉最后一个逗号

lie = Split(lie, ",") ' 以逗号为分隔符,将字符串转为数组

zhi = left(len(zhi)-1)

zhi = Split(zhi, ",")

shu = left(len(shu)-1)

shu = Split(shu, ",")

大概就是这样,不知我对表的结构有没有理解错误。

拿到cursor对象后调用Cursor类的方法即可 如: String[] strs = new String[cursor.getCount()]String columnName=""int position = 0// cursor.moveToPosition(position)cursor.moveToFirst()while (cursor.moveToNext()) { int inde


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/6764498.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-28
下一篇 2023-03-28

发表评论

登录后才能评论

评论列表(0条)

保存