> Thanks Alejandro,
> I have found the solution.
> Problem is not the Oledb, but the CursorLocation.
> So if don't give the CursorLocation as adUseClient, it is giving error,
with
> adUseClient it is working.
> Thanks again
> JS
> > Why do not you try using oledb provider?
> > I ran the same code and i did not get any error.
> > Here is what i did.
> > Private Sub cmd6_Click()
> > Dim cn As ADODB.Connection
> > Dim rs As ADODB.Recordset
> > Set cn = New ADODB.Connection
> > Set rs = New ADODB.Recordset
> > On Error GoTo ErrorHandler
> > With cn
> > .Provider = "sqloledb"
> > .ConnectionString = "data source=myserver;initial
> > catalog=northwind;trusted_connection=yes"
> > .CursorLocation = adUseClient
> > .Errors.Clear
> > .Open
> > End With
> > cn.Execute "create table #temp(pkfld int)", , adCmdText +
> > adExecuteNoRecords
> > Set rs = cn.Execute("select employeeid from employees", , adCmdText)
> > cn.Execute "insert #temp values(1)", , adCmdText + adExecuteNoRecords
> > ExitSub:
> > On Error Resume Next
> > rs.Close
> > cn.Close
> > Set rs = Nothing
> > Set cn = Nothing
> > Exit Sub
> > ErrorHandler:
> > MsgBox Err.Description
> > Resume ExitSub
> > End Sub
> > > Hi Guys
> > > Took me some time to experiment and found the actual reason for the
> error.
> > > Looks like there is some problem with ADO.
> > > It works fine, if nothing else being done on the same Connection
object,
> > but
> > > even if you issue any other queries, it starts giving errors. I tried
> even
> > > after Disabling the Pooling, still it gives the error.
> > > So here are the Error Free and Error Prone code, for you guys to
> > experiment:
> > > Error Free code
> > > =======
> > > conn.Open "DSN=Scope21;UID=sa;PWD=;"
> > > conn.Execute "create table #tmp1(ID int)"
> > > conn.Execute "insert #tmp1 values (1)"
> > > Error Prone code
> > > ============
> > > conn.Open "DSN=Scope21;UID=sa;PWD=;"
> > > conn.Execute "create table #tmp1(ID int)"
> > > 'Extra query, which causes the disaster
> > > Set rs = conn.Execute("select * from customer")
> > > 'Now here it will give error
> > > conn.Execute "insert #tmp1 values (1)"
> > > I think MS guys should can better comment on this.
> > 1/>
> > > > Thanks a ton guys for suggestions.
> > > > But my problem still persists. From Query Analyzer it works fine.
But
> I
> > m
> > > > using ADO 2.1 from VB.
> > > > So after establishing a connection, I execute a batch like this:
> > > > Cn.Execute "CREATE TABLE #Temp (CompanyId char(3))"
> > > > After that I run a SP using a Command object. So here it gives me
the
> > > error
> > > > Object name #Temp not found. This time I m using the same
Connection
> > > object
> > > > Cn.
> > > > Any more suggestions ???????????
> > > > Regards:
> > > > Joga Singh
> > > > About temp tables created with one # sign:
> > > > Creating a temp table in a batch leaves the temp table until your
spid
> > > > (connection) is closed.
> > > > Creating a temp table in a procedure deletes the temp table at the
end
> > of
> > > > the procedure.
> > > > A temp table is visible from procB if procB is called from procA
after
> a
> > > > temp table has been created.
> > > > Creating #mytab in a batch. Then, executing procA which creates
> #mytab
> > > will
> > > > hide the first #mytab created; you will have two #mytab temp tables.
> > One
> > > > will be accessible inside the procA and the other will be hidden to
> it.
> > > > >Hi,
> > > > >According to BOL, a #Temp table is removed, when the connection is
> > closed
> > > > to
> > > > >SQL Server. But I m experiencing an opposite behaviour.
> > > > >From my Qey Analyzer, I m executing a SP, which creates a #Temp
> table.
> > So
> > > > >when I execute another SP, that #Temp table is not visible, it
gives
> > the
> > > > >error Invalid object name '#Temp' table name.
> > > > >Is there anybody who could just explain the real situation ??????
> > > > >Regards:
> > > > >Joga Singh