VB二维数组如何添加到ACCESS数据库中!!
PrivateSubButton1_Click(senderAsObject,eAsEventArgs)HandlesButton1.ClickDimvar()AsStr...
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim var() As String
var = Split(TextBox1.Text, vbCrLf)
Dim i As Integer, j As Integer
For i = 0 To var.Length - 1
Dim s() As String
s = Split(Replace(var(i), " ", "+"), "+")
Dim str(var.Length - 1, s.Length - 1) As String
For j = 0 To s.Length - 1
str(i, j) = s(j)
Next
Next
End Sub
我用你的办法解决了前面一个问题,现在又有一个问题就是我想把分组输出的结果写入数据库应该怎么做,数据库表如下图!!! 展开
Dim var() As String
var = Split(TextBox1.Text, vbCrLf)
Dim i As Integer, j As Integer
For i = 0 To var.Length - 1
Dim s() As String
s = Split(Replace(var(i), " ", "+"), "+")
Dim str(var.Length - 1, s.Length - 1) As String
For j = 0 To s.Length - 1
str(i, j) = s(j)
Next
Next
End Sub
我用你的办法解决了前面一个问题,现在又有一个问题就是我想把分组输出的结果写入数据库应该怎么做,数据库表如下图!!! 展开
1个回答
展开全部
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strsql As String
Dim cnstr As String
conn.CursorLocation = adUseClient
cnstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= db1.mdb;Jet OLEDB:Database Password="
conn.ConnectionString = cnstr
conn.Open cnstr
strsql = "select * from ssq"
rs.Open strsql, conn, 3, 3
For i = 0 To var.Length - 1
rs.addnew
For j = 0 To s.Length - 1
rs(j)=str(i,j)
next
rs.update
next
rs.close
conn.close
'记得引用microsoft activex data objects x.x library
Dim rs As New ADODB.Recordset
Dim strsql As String
Dim cnstr As String
conn.CursorLocation = adUseClient
cnstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= db1.mdb;Jet OLEDB:Database Password="
conn.ConnectionString = cnstr
conn.Open cnstr
strsql = "select * from ssq"
rs.Open strsql, conn, 3, 3
For i = 0 To var.Length - 1
rs.addnew
For j = 0 To s.Length - 1
rs(j)=str(i,j)
next
rs.update
next
rs.close
conn.close
'记得引用microsoft activex data objects x.x library
追问
追答
等等给你写一个例子。。因为不知道你的数组里是否包含id ,所以我这里的id用了自动编号,可以自己稍作修改
看附件
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询