vb想要同时往表里插入多个记录 结果提示 SQL语句的结束位置缺少分号 高手帮我看下怎么回事
Dimf()AsString,h()AsString,g()AsStringDimUAsString,VAsString,WAsStringU=Text2.Textf=S...
Dim f() As String, h() As String, g() As String
Dim U As String, V As String, W As String
U = Text2.Text
f = Split(U, ",")
V = Text3.Text
h = Split(V, ",")
W = Text4.Text
g = Split(W, ",")
Dim rs_dj As New ADODB.Recordset
Dim conn As ADODB.Connection
Dim Sql As String
Set conn = New ADODB.Connection
conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=True"
conn.Open conn
Sql = "insert into 指标信息 (产品名称,评价指标,指标权重,等级标准值) values('" & Trim(Text1.Text) & "','" & f(0) & "','" & h(0) & "','" & g(0) & "')"
Sql = Sql & "insert into 指标信息 (产品名称,评价指标,指标权重,等级标准值) values('" & Trim(Text1.Text) & "','" & f(1) & "','" & h(1) & "','" & g(1) & "')"
rs_dj.Open Sql, conn, adOpenStatic, adLockOptimistic
MsgBox "tian jia cheng gong"
谢谢了 展开
Dim U As String, V As String, W As String
U = Text2.Text
f = Split(U, ",")
V = Text3.Text
h = Split(V, ",")
W = Text4.Text
g = Split(W, ",")
Dim rs_dj As New ADODB.Recordset
Dim conn As ADODB.Connection
Dim Sql As String
Set conn = New ADODB.Connection
conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=True"
conn.Open conn
Sql = "insert into 指标信息 (产品名称,评价指标,指标权重,等级标准值) values('" & Trim(Text1.Text) & "','" & f(0) & "','" & h(0) & "','" & g(0) & "')"
Sql = Sql & "insert into 指标信息 (产品名称,评价指标,指标权重,等级标准值) values('" & Trim(Text1.Text) & "','" & f(1) & "','" & h(1) & "','" & g(1) & "')"
rs_dj.Open Sql, conn, adOpenStatic, adLockOptimistic
MsgBox "tian jia cheng gong"
谢谢了 展开
展开全部
分两次执行:
Sql = "insert into 指标信息 (产品名称,评价指标,指标权重,等级标准值) values('" & Trim(Text1.Text) & "','" & f(0) & "','" & h(0) & "','" & g(0) & "')"
conn.Execute sql
Sql = "insert into 指标信息 (产品名称,评价指标,指标权重,等级标准值) values('" & Trim(Text1.Text) & "','" & f(1) & "','" & h(1) & "','" & g(1) & "')"
conn.Execute sql
MsgBox "tian jia cheng gong"
Sql = "insert into 指标信息 (产品名称,评价指标,指标权重,等级标准值) values('" & Trim(Text1.Text) & "','" & f(0) & "','" & h(0) & "','" & g(0) & "')"
conn.Execute sql
Sql = "insert into 指标信息 (产品名称,评价指标,指标权重,等级标准值) values('" & Trim(Text1.Text) & "','" & f(1) & "','" & h(1) & "','" & g(1) & "')"
conn.Execute sql
MsgBox "tian jia cheng gong"
展开全部
两个insert into 好象被你放用Sql = Sql & "insert ....放到一行里了。
试试执行两次 rs_dj.Open Sql, conn, adOpenStatic, adLockOptimistic
试试执行两次 rs_dj.Open Sql, conn, adOpenStatic, adLockOptimistic
更多追问追答
追问
不行 还是同样的出错提示
追答
你把sql语句打印出来,直接进sql query 看能不能运行。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Sql = Sql & ";" & "insert into 指标信息 (产品名称,评价指标,指标权重,等级标准值) values('" & Trim(Text1.Text) & "','" & f(1) & "','" & h(1) & "','" & g(1) & "')"
参考:http://www.w3school.com.cn/sql/sql_syntax.asp
参考:http://www.w3school.com.cn/sql/sql_syntax.asp
追问
还是不行 郁闷
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询