clear me please

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

clear me please

Post by sal21 »

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

User avatar
HansV
Administrator
Posts: 78535
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: clear me please

Post by HansV »

What exactly do you want to do?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: clear me please

Post by sal21 »

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?

User avatar
HansV
Administrator
Posts: 78535
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: clear me please

Post by HansV »

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)
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: clear me please

Post by sal21 »

OK! Tks, as usual.