Database keyword is larger than that of excel order are not the same as those for VB how to write after you connect
CodePudding user response:
set s=app_excel. Workbooks (1) activesheet
S.c ells (1, 1)="keywords"
S.c ells (1, 2)="hits"
I=2
Eof
the do while not rs.S.c ells (I, 1)=rs. Fileds (" keyword ")
S.c ells (I, 2)=rs. Fileds (" hits ")
Rs. Movenext
I=I + 1
Loop
CodePudding user response:
First with external database query, a you will Excel data import, such as rs1, then on the database connection is established, such as toll:Do Until rs1. EOF
Cn2. Execute "UPDATE yourTable SET [on]=" & amp; Rs1! Click & amp; "WHERE [key words]='" & amp; Rs1! Key words & amp; "'
"Rs1. MoveNext
Loop
Cn2. Close
The Set cn2=Nothing
Rs1. Close
The Set of rs1=Nothing
CodePudding user response:
cn2. Execute "UPDATE yourTable SET [on]=" & amp; Rs1! Click & amp; "WHERE [key words]='" & amp; Rs1! Key words & amp; "'
"
CodePudding user response:
Thank you for the great godCodePudding user response:
WHERE [key words]='" & amp; Rs1! Key words & amp; "' not found method?????CodePudding user response:
Your rs1 query, to include "keyword" field, of course, you can also use the way of specified field name:cn2. Execute "UPDATE yourTable SET [on]=" & amp; Rs1! Click & amp; "WHERE [key words]='" & amp; Rs1. Fields (1) & amp; "'
"
CodePudding user response:
Evencn2. Execute "UPDATE yourTable SET [on]=" & amp; Rs1. Fields (0) & amp; "WHERE [key words]='" & amp; Rs1. Fields (1) & amp; "'
"
CodePudding user response:
The great spirit of QQCodePudding user response:
Dim SJKSJB As String
Dim excsjb As String
Dim As Integer I
Excsjb="Provider=MSDASQL. 1; Persist Security Info=False; Extended Properties='DSN=Excel Files; DBQ="& amp; Text1. Text & amp; "'; DriverId=1046; MaxBufferSize=2048; PageTimeout=5;"
SJKSJB="Provider=Microsoft. Jet. The OLEDB. 4.0. Password=; Data Source="& amp; App. The Path & amp; "\ db1. MDB; Persist Security Info=True "
Dim cnnExc As ADODB. Connection, cnnSjk As ADODB. Connection
CnnExc. Open excsjb
CnnSjk. Open SJKSJB
Dim exc1 As New ADODB library. You, exc2 As New ADODB library. You, sjk1 As New ADODB library. You, sjk2 As New ADODB. You
Exc2. Open the "select * from [sheet1 $]", cnnExc
Sjk2. Open the "select * from GJC," cnnSjk, 1, 3 'if there is a problem can't separate the search field to add
Sjk2. AddNew
Sjk2. Fields (keywords)=exc2. Fields (keywords)
Sjk2. Update
Exc2. Close
Sjk2. Close
Dim ri As String
Dim sjk2b As New ADODB. You
Ri="select * from cjyh WHERE date='#" & amp; DTPicker1. Value & amp; "# '
"Sjk2b. Open the "select * from GJC," cnnSjk
Sjk1. Open the "select * from cjyh", cnnSjk, 1, 3
If ri="" Then
Sjk1. AddNew
Sjk1. Fields (keywords)=sjk2. Fields (keywords)
Sjk1. Update
Sjk2. MoveNext
For I=0 To sjk2b. RecordCount - 1
Sjk1. AddNew date, "Value # # dtpicker1."
Next I
Sjk1. Update
Sjk1. Close
Sjk2. Close
End the If
Sjk1. Open the "select * from cjyh", cnnSjk, 1, 3
Exc2. Open the "select * from [sheet1 $]", cnnExc,
Do Until exc2. EOF
Sjk1. Execute "UPDATE cjyh SET [visitors]=" & amp; Exc2. Fields (1) & amp; "The WHERE keyword='" & amp; Exc2. Fields (0) & amp; "' and where [date]='#" & amp; DTPicker1. Value & amp; "# '
"Exc1. MoveNext
Loop
Sjk1. Close
The Set sjk1=Nothing
Exc2. Close
The Set exc2=Nothing
CodePudding user response:
Still hint. Field, there is no method or dataCodePudding user response:
CnnSjk. Execute "... "Of course not the Execute method records set,
CodePudding user response:
Should use the open?