asp INSERT INTO 语句的语法错误。
<%OptionExplicitDimConnStr_DB1DimConnStr_DB2ConnStr_DB2="Provider=Microsoft.Jet.OLEDB...
<%
Option Explicit
Dim ConnStr_DB1
Dim ConnStr_DB2
ConnStr_DB2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("..\DB\chatdb.mdb")&";"
ConnStr_DB1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("..\DB\LOVE.mdb")&";"
Dim Conn
Dim Rs
Dim SQL
Dim RowsMatrix
Dim N
Dim i
Dim user,password
SQL = "select username,password from love_main;"
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")
Conn.Open ConnStr_DB1
Rs.Open SQL, Conn, 1, 1
N=Rs.RecordCount'获得数据库记录条数
If N>0 Then
RowsMatrix = Rs.GetRows()'将recordset记录集提取到一个二维数组中
End If
Rs.Close
Conn.Close
Set Rs = Nothing
Rs = Null
If N>0 Then
Conn.Open ConnStr_DB2
if Conn.State=1 then Response.Write("连接成功")
For i=0 To N-1
Response.Write RowsMatrix(0,i)
Response.Write RowsMatrix(1,i)
Response.Write "<BR>"
Conn.Execute "insert into userinfo(userid,password)values('"&RowsMatrix(0,i)&"','"&RowsMatrix(1,i)&"')"
Next
Conn.Close
End If
Set Conn = Nothing
Conn = Null
%>
提示:INSERT INTO 语句的语法错误。如果删除Conn.Execute "insert into userinfo(userid,password)values('"&RowsMatrix(0,i)&"','"&RowsMatrix(1,i)&"')" 则能顺利打印出账号和密码。上面的语句写在同一行上的。两个数据库的表不一样。
userinfo的userid和password字段都是文本类型 展开
Option Explicit
Dim ConnStr_DB1
Dim ConnStr_DB2
ConnStr_DB2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("..\DB\chatdb.mdb")&";"
ConnStr_DB1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("..\DB\LOVE.mdb")&";"
Dim Conn
Dim Rs
Dim SQL
Dim RowsMatrix
Dim N
Dim i
Dim user,password
SQL = "select username,password from love_main;"
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")
Conn.Open ConnStr_DB1
Rs.Open SQL, Conn, 1, 1
N=Rs.RecordCount'获得数据库记录条数
If N>0 Then
RowsMatrix = Rs.GetRows()'将recordset记录集提取到一个二维数组中
End If
Rs.Close
Conn.Close
Set Rs = Nothing
Rs = Null
If N>0 Then
Conn.Open ConnStr_DB2
if Conn.State=1 then Response.Write("连接成功")
For i=0 To N-1
Response.Write RowsMatrix(0,i)
Response.Write RowsMatrix(1,i)
Response.Write "<BR>"
Conn.Execute "insert into userinfo(userid,password)values('"&RowsMatrix(0,i)&"','"&RowsMatrix(1,i)&"')"
Next
Conn.Close
End If
Set Conn = Nothing
Conn = Null
%>
提示:INSERT INTO 语句的语法错误。如果删除Conn.Execute "insert into userinfo(userid,password)values('"&RowsMatrix(0,i)&"','"&RowsMatrix(1,i)&"')" 则能顺利打印出账号和密码。上面的语句写在同一行上的。两个数据库的表不一样。
userinfo的userid和password字段都是文本类型 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询