ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Several sql queries with the same recordset (https://www.excelbanter.com/excel-programming/315532-several-sql-queries-same-recordset.html)

fbonnard[_2_]

Several sql queries with the same recordset
 

When you said

set Cnn=New ADODB.Connection
Cnn.Open Cn
Cnn.Execute sql ' your SQLS starting UPDATE (does not return a recor
set)
Cnn.Execute sql ' your SQLS starting INSERT (does not return a recor
set)


What is cn ?

How can i use RecordCount and CopyFromRecordset if i need to make
select

--
fbonnar
-----------------------------------------------------------------------
fbonnard's Profile: http://www.excelforum.com/member.php...fo&userid=1597
View this thread: http://www.excelforum.com/showthread.php?threadid=27446


AA2e72E

Several sql queries with the same recordset
 
Refer to the Excel VBA help file for information on CopyFomRecordSet.

"fbonnard" wrote:


When you said

set Cnn=New ADODB.Connection
Cnn.Open Cn
Cnn.Execute sql ' your SQLS starting UPDATE (does not return a record
set)
Cnn.Execute sql ' your SQLS starting INSERT (does not return a record
set)


What is cn ?

How can i use RecordCount and CopyFromRecordset if i need to make a
select ?


--
fbonnard
------------------------------------------------------------------------
fbonnard's Profile: http://www.excelforum.com/member.php...o&userid=15977
View this thread: http://www.excelforum.com/showthread...hreadid=274467



AA2e72E

Several sql queries with the same recordset
 
Refer to the code in your original query .... relevant part pasted here (see
line 2):

If (Range("B" & i).Value 0) Then
rs.Open mySql4, cn, adOpenStatic
rs.Close
Else
rs.NextRecordset mySql3, cn, adOpenStatic
rs.Close
End If

cn in this context is either an ADODB.Connection object that has been opened
or it is simply a string that can be used to connect to the databas,
something like:

cn="DSN=your DSN;UID=your userid;PWD=your password"

"fbonnard" wrote:


When you said

set Cnn=New ADODB.Connection
Cnn.Open Cn
Cnn.Execute sql ' your SQLS starting UPDATE (does not return a record
set)
Cnn.Execute sql ' your SQLS starting INSERT (does not return a record
set)


What is cn ?

How can i use RecordCount and CopyFromRecordset if i need to make a
select ?


--
fbonnard
------------------------------------------------------------------------
fbonnard's Profile: http://www.excelforum.com/member.php...o&userid=15977
View this thread: http://www.excelforum.com/showthread...hreadid=274467




All times are GMT +1. The time now is 01:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com