VB的SQL 第一行:‘X’附近有语法错误
不知那里出错了,各位大神帮忙看下,谢谢。代码如下:PrivateSubCommand1_Click()DimrsAsADODB.RecordsetDimconnAsADO...
不知那里出错了,各位大神帮忙看下,谢谢。代码如下:
Private Sub Command1_Click()
Dim rs As ADODB.Recordset
Dim conn As ADODB.Connection
Dim cnstr As String
Dim fname As String
Dim FileName As String
Dim rename As String
Dim sql1 As String
Dim k, i, j As Integer
Dim P As Integer
Set conn = New ADODB.Connection
Set conn = New ADODB.Connection
cnstr = "driver={sql server}; server=LI; database=syzx; uid=sa; pwd="
conn.Open cnstr
Set rs = New ADODB.Recordset
k = 0
j = 0
For i = 0 To File1.ListCount - 1
FileName = File1.List(i)
P = InStrRev(FileName, ".", -1, 1)
fname = Left(FileName, P - 1)
sql1 = "select * from test where 身份证件号=" & fname
rs.Open sql1, conn, adOpenDynamic, adLockBatchOptimistic
If rs.BOF = True Or rs.EOF = True Then
List1.List(j) = fname
j = j + 1
Else
List2.List(k) = fname
k = k + 1
End If
rs.Close
Next i
End Sub 展开
Private Sub Command1_Click()
Dim rs As ADODB.Recordset
Dim conn As ADODB.Connection
Dim cnstr As String
Dim fname As String
Dim FileName As String
Dim rename As String
Dim sql1 As String
Dim k, i, j As Integer
Dim P As Integer
Set conn = New ADODB.Connection
Set conn = New ADODB.Connection
cnstr = "driver={sql server}; server=LI; database=syzx; uid=sa; pwd="
conn.Open cnstr
Set rs = New ADODB.Recordset
k = 0
j = 0
For i = 0 To File1.ListCount - 1
FileName = File1.List(i)
P = InStrRev(FileName, ".", -1, 1)
fname = Left(FileName, P - 1)
sql1 = "select * from test where 身份证件号=" & fname
rs.Open sql1, conn, adOpenDynamic, adLockBatchOptimistic
If rs.BOF = True Or rs.EOF = True Then
List1.List(j) = fname
j = j + 1
Else
List2.List(k) = fname
k = k + 1
End If
rs.Close
Next i
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询