clear me please

clear me please

Postby sal21 » 10 May 2010, 20:29

Based this piece of code to SELECT is required to open a table mytable ?????

Se tRS = New ADODB.Recordset
RS .Open "mytable ",CONN, adOpenKeyset, adLockPessimistic, adCmdTable

strSQL = "SELECT * FROM mytable WHERE RAPPORTO = '" & RAPPORTO & "'"
Set RS = GAF_CONN.Execute(strSQL)

If No tRS .EOF Then
...ecccc
end if
Post=15821
User avatar
sal21
BronzeLounger
 
Posts: 1458
Joined: 26 Apr 2010, 17:36

Re: clear me please

Postby HansV » 10 May 2010, 20:39

What exactly do you want to do?
Regards,
Hans
Post=15823
User avatar
HansV
Clever Clogs
 
Posts: 24242
Joined: 16 Jan 2010, 00:14
Location: Leiden, The Netherlands

Re: clear me please

Postby sal21 » 11 May 2010, 06:17

HansV wrote:What exactly do you want to do?


In effect before to use this piece of code:
Code: Select all
strSQL = "SELECT * FROM mytable WHERE RAPPORTO = '" & RAPPORTO & "'"
Set RS = GAF_CONN.Execute(strSQL)


is required to open the table with:

Code: Select all
Se tRS = New ADODB.Recordset
RS .Open "mytable ",CONN, adOpenKeyset, adLockPessimistic, adCmdTable


or i can use directlly the select statement without open the table?
Post=15844
User avatar
sal21
BronzeLounger
 
Posts: 1458
Joined: 26 Apr 2010, 17:36

Re: clear me please

Postby HansV » 11 May 2010, 06:56

You don't need to open the table first. You can either use

Code: Select all
Dim RS As ADODB.Recordset
strSQL = "SELECT * FROM mytable WHERE RAPPORTO = '" & RAPPORTO & "'"
Set RS = GAF_CONN.Execute(strSQL)

or

Code: Select all
Dim RS As New ADODB.Recordset
strSQL = "SELECT * FROM mytable WHERE RAPPORTO = '" & RAPPORTO & "'"
RS.Open strSQL, GAF_CONN, adOpenKeyset, adLockPessimistic, adCmdText

(But not both - choose only one)
Regards,
Hans
Post=15849
User avatar
HansV
Clever Clogs
 
Posts: 24242
Joined: 16 Jan 2010, 00:14
Location: Leiden, The Netherlands

Re: clear me please

Postby sal21 » 11 May 2010, 07:18

OK! Tks, as usual.
Post=15851
User avatar
sal21
BronzeLounger
 
Posts: 1458
Joined: 26 Apr 2010, 17:36


Return to Access/SQL

Who is online

Users browsing this forum: Ahrefsbot [Bot], CCBot [Bot] and 0 guests