Article ID: 190124
Article Last Modified on 11/7/2003
Dim ws As Workspace
Dim cn As Connection
Dim strConnect as string
Dim strSQL as string
Set ws = DBEngine.CreateWorkspace("", "", "", dbUseODBC)
Set cn = ws.OpenConnection("", , ,
"ODBC;DSN=Pubs;Database=Pubs;UID=<username>;PWD=<strong password>")
strSQL = "CREATE TABLE #test (field1 VARCHAR(20) NULL)" & vbCrLf & _
"CREATE TABLE TestTemp(field1 VARCHAR(20) NULL)" & vbCrLf & _
"INSERT INTO #test(field1) SELECT fname FROM Employee" & vbCrLf & _
"INSERT INTO TestTemp(field1) SELECT field1 FROM #test"
cn.Execute strSQL
SELECT * FROM TestTemp
DROP TABLE TestTemp
Dim ws As Workspace
Dim cn As Connection
Dim strConnect as string
Dim strSQL as string
Set ws = DBEngine.CreateWorkspace("", "", "", dbUseODBC)
Set cn = ws.OpenConnection("", , ,
"ODBC;DSN=Pubs;Database=Pubs;UID=<username>;PWD=<strong password>")
strSQL = "CREATE TABLE #test (field1 VARCHAR(20) NULL)" & vbCrLf & _
"INSERT INTO #test(field1) SELECT fname FROM Employee"
cn.Execute strSQL, dbExecDirect
strSQL = "CREATE TABLE TestTemp(field1 VARCHAR(20) NULL)" & vbCrLf & _
"INSERT INTO TestTemp(field1) SELECT field1 FROM #test"
cn.Execute strSQL, dbExecDirect
You should see rows returned in the results windows. This demonstrates
that the temporary table was created and its scope was not limited to a
prepared statement (temporary stored procedure) but the database connection.
Dim ws As Workspace
Dim cn As Connection
Dim strConnect as string
Dim strSQL as string
Set ws = DBEngine.CreateWorkspace("", "", "", dbUseODBC)
Set cn = ws.OpenConnection("", , ,
"ODBC;DSN=Pubs;Database=Pubs;UID=<username>;PWD=<strong password>")
strSQL = "CREATE TABLE #test (field1 VARCHAR(20) NULL)"
cn.Execute strSQL
'This statement results in an error.
strSQL = "INSERT INTO #test(field1) SELECT fname FROM Employee"
cn.Execute strSQL
Additional query words: kbDSupport kbdse kbvbp600 kbvbp500 kbDAO350 kbDAO kbSQLServ kbDatabase
Keywords: kbprb KB190124