mssql server 2012 express

HMG en Español

Moderator: Rathinagiri

User avatar
jairpinho
Posts: 420
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Contact:

Re: mssql server 2012 express

Post by jairpinho »

jorge.posadas wrote: Wed Apr 17, 2019 3:11 pm jairpinho

This an example I hope help you
Gracias Jorge, funcionó perfectamente sin odbc conexión nativa sigue el ejemplo para todos. espero recibir más ejemplos para otros tipos de conexión rdd o odbc para dejar como exeomplo para el grupo

english
Thanks Jorge, worked perfectly without odbc native connection follows example for all. I hope to receive more examples for other types of connection rdd or odbc to leave as exeomplo for the group
Attachments
AD0_NATIVE.zip
(1.49 MiB) Downloaded 298 times
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
Tiger
Posts: 70
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

Re: mssql server 2012 express

Post by Tiger »

Hi jairpinho,

Thanks for your sample "AD0_NATIVE.zip ", it helps me to connect to the MSSQL now. And I just wonder how to export the query result to excel file. Can anyone guide me to do it? I try to search the form but I can't get it.

Tiger
User avatar
AUGE_OHR
Posts: 2062
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: mssql server 2012 express

Post by AUGE_OHR »

hi,
Tiger wrote: Wed Sep 04, 2019 3:50 am And I just wonder how to export the query result to excel file. Can anyone guide me to do it? I
there is a Excel Demo in c:\hmg.3.4.4\SAMPLES\Controls\OLE\demo.prg

create a empty worksheet and pass hole Array like this

Code: Select all

PROCEDURE Excel(aData)
LOCAL oExcel, oHoja

   oExcel := CreateObject( "Excel.Application" )
   oExcel:WorkBooks:Add()
   oHoja := oExcel:ActiveSheet()
   // fill Sheet with Array
   oHoja:value := aData
have fun
Jimmy
Tiger
Posts: 70
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

Re: mssql server 2012 express

Post by Tiger »

AUGE_OHR wrote: Wed Sep 04, 2019 9:45 pm hi,
Tiger wrote: Wed Sep 04, 2019 3:50 am And I just wonder how to export the query result to excel file. Can anyone guide me to do it? I
there is a Excel Demo in c:\hmg.3.4.4\SAMPLES\Controls\OLE\demo.prg

create a empty worksheet and pass hole Array like this

Code: Select all

PROCEDURE Excel(aData)
LOCAL oExcel, oHoja

   oExcel := CreateObject( "Excel.Application" )
   oExcel:WorkBooks:Add()
   oHoja := oExcel:ActiveSheet()
   // fill Sheet with Array
   oHoja:value := aData
Thank for the hint, I will try this way.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: mssql server 2012 express

Post by mol »

Hi!
I want to reftresh this topic.
I'm trying to rebuild my application, but, it doesn't want to connect to MSSQL server
My connection string:
cConStr := "Driver={SQL Server};"+;
"Server=" + cSQLSerwer + ";"+;
"Database="+ cSQLBaza + ";"+;
"Trusted_Connection=yes" + ";"+;
"Integrated Security=SSPI;" +;
"Uid=" + cSQLUser+ ";"+;
"Pwd="+ cSQLPassword +";"
lOK := hb_RDDINFO( RDDI_CONNECT, { "ODBC", cConStr })

lOK should be 0 if not connected and <> 0 if connected.
But, I'm getting an array as a result, containing exactly what I pass to RDDINFO - { "ODBC", cConStr }

Do you have any idea what can be wrong?
Any other ways to connect to mssql server?
jparada
Posts: 430
Joined: Fri Jan 23, 2009 5:18 pm

Re: mssql server 2012 express

Post by jparada »

Hi,

try ADO, small example:

Code: Select all

IF ( oConnection := win_OleCreateObject( "ADODB.Connection" ) ) == NIL
    ? "No es posible crear objeto conexión", win_OleErrorText()
    RETURN NIL
  ENDIF

  BEGIN SEQUENCE WITH {|oError| BREAK( oError ) }    
    oConnection:Open("Provider=SQLNCLI11;Server=SERVERNAME\INSTANCENAME;Database=DBNAME;Uid=USER;Pwd=PASS;" )		
  RECOVER USING oError
    ? "Error al intentar conectar a la base de datos " +  E"\n" + hb_Utf8ToStr(oError:Description)
    RETURN NIL
  END SEQUENCE

  oRs := win_OleCreateObject( "ADODB.Recordset" )
  cQry1 := "SELECT TOP 5 ccodigoagente AS Agente, cnombreagente AS Nombre FROM admAgentes"

  BEGIN SEQUENCE WITH {|oError| BREAK( oError ) }    
    oRs:Open(cQry1, oConnection)
  RECOVER USING oError
    ? "Error al realizar la consulta " +  E"\n" + hb_Utf8ToStr(oError:Description)
  END SEQUENCE
  
  oRs:MoveFirst()
  Do While !oRs:Eof()
    AADD( aData , { oRs:Fields( "Nombre" ):Value, oRs:Fields( "Agente" ):Value  } )    
    oRs:MoveNext()
  ENDDO

  oRs:Close()
  oConnection:Close()
Regards,
Javier
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: mssql server 2012 express

Post by mol »

Thank you! I'll try this. How about speed?
jparada
Posts: 430
Joined: Fri Jan 23, 2009 5:18 pm

Re: mssql server 2012 express

Post by jparada »

Hi,

Compared against what?, anyway, I have no comparison parameter, since I personally have not used any other connection method, I only use ADO.

Regards,
Javier
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: mssql server 2012 express

Post by mol »

As I understand well, in ADO, when I get data from serwer, I must put it into table or .dbf file.
Using SQLMIX, I'm getting data into temporary table. There is a minimal change to old code to use this way of using sql server.
Am I wrong?
Post Reply