Page 1 of 1

error with temporal table

Posted: Tue Mar 05, 2019 12:46 am
by artu01
Guys:

I have create a temporary table in MSSQL with ADO from my program with succesful, but that table does not see it in the Microsoft SQL Server Management, someone know where is it, in tempdb?

The table has a single field and I insert a record, Up there all right, after I want to show its contents but I get this Message:

Error description: (DOS Error -2147352567) WINOLE/1007 No se encontró el elemento en la colección que corresponde al nombre o el ordinal solicitado. (0x800A0CC1): ADODB.Recordset


this is my code:

Code: Select all | Expand



    oCon:=AbreConexBd()

    cSQL := "CREATE TABLE #ppru"
    cSQL += "("
    cSQL += "numero CHAR(6) NOT NULL "
    cSQL += ")"

   Try
      oCon:Execute( cSQL )
   Catch
      MsgInfo( "Table Create ppru Failed" )
      oDlg:End()
      Return(.f.)
   End try

oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType     := 1        // opendkeyset
oRs:CursorLocation := 3        // local cache
oRs:LockType       := 3        // lockoportunistic

cSQL := "SELECT * from [#ppru]"

TRY
  oRS:Open(cSQL,oCon )
CATCH oErr
  MsgInfo( "Error in Opening #ppru table" )
  oCon:Close()
  RETURN(.F.)
END TRY

 oRs:CLose()

  cSQL := " insert into [#ppru] (numero) "
  cSQL += "values('123456') "

oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType     := 1        // opendkeyset
oRs:CursorLocation := 3        // local cache
oRs:LockType       := 3        // lockoportunistic

oRS:Open(cSQL,oCon )
msgalert(oRs:Fields("numero"):Value)  //>>>>>>> AQUI ME BOTA ERROR <<<<<<<<<<<<<<



Function AbreConexBD()
  LOCAL cCString, oError, oCon1

  xPROVIDER := "SQLOLEDB"                  // oledb provider
  xSOURCE   := "PYSASERVER"                // sql server name
  xCATALOG  := "PysaBD"                    // sql server database
  xUSERID   := "sa"
  xPASSWORD := "Pysa123456"
  xConnect  := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD

  TRY
    oCon1 := CreateObject( "ADODB.Connection" )
    oCon1:Open( xConnect )
  CATCH oError
     MsgStop( oError:Description )
  END
Return oCon1

 

Re: error with temporal table

Posted: Tue Mar 05, 2019 3:19 pm
by nageswaragunupudi
Temporary tables are seen only by the connection that created it and is deleted when that connection is closed. They are not seen by a different connection. Management Studio's connection is different from the connection you created in your application. So, Mangement studio cannot see the temporary table you created. That is the correct behaviour.

Re: error with temporal table

Posted: Sat Mar 09, 2019 12:29 am
by artu01
nageswaragunupudi wrote:Temporary tables are seen only by the connection that created it and is deleted when that connection is closed. They are not seen by a different connection. Management Studio's connection is different from the connection you created in your application. So, Mangement studio cannot see the temporary table you created. That is the correct behaviour.


Thanks mr. rao always clear in the explanation