Page 1 of 3

mssql server 2012 express

Posted: Sun Apr 14, 2019 12:08 am
by jairpinho
alguien podría proporcionar un ejemplo de conexión mssql express 2012 que funcione con hmg ide. las pruebas se realizaron con el controlador odbc en windows. La prueba fue hecha con todos los ejemplos del foro pero no hace conexión. ¿existe una manera de conectar directamente en el banco sin usar origen de datos odbc de windows?


english
could anyone provide an example of connection mssql express 2012 that works with hmg ide. Tests were done with odbc driver on windows. test were done with all examples of the forum but does not make connection. is there a way to connect directly to the database without using windows odbc data source?

Re: mssql server 2012 express

Posted: Mon Apr 15, 2019 5:18 am
by bpd2000
Hi,
Try to connect sql server with utility, if success I will guide you further
Note : [1] Provide IP address of server when default instance, or provide full address like "192.168.1.25\mydata"
[2] user nage will be used as "SA" [SQL must be installed in mixed mode], [3] Provide SA user password
refer
http://expresstechnology.com/knowledgeb ... ql-server/

Use this utility at your own risk, This is for checking connectivity only, do not change any data through this utility.

Re: mssql server 2012 express

Posted: Mon Apr 15, 2019 3:00 pm
by jorge.posadas
Jair,

Yo probé tu EXE y si me da resultado, es decir me conecto al server, selecciono una base de datos y luego selecciono la tabla y me muestra todos los datos, asi que todo funciona bien

Re: mssql server 2012 express

Posted: Mon Apr 15, 2019 10:02 pm
by jairpinho
bpd2000 wrote: Mon Apr 15, 2019 5:18 am Hi,
Try to connect sql server with utility, if success I will guide you further
Note : [1] Provide IP address of server when default instance, or provide full address like "192.168.1.25\mydata"
[2] user nage will be used as "SA" [SQL must be installed in mixed mode], [3] Provide SA user password
refer
http://expresstechnology.com/knowledgeb ... ql-server/

Use this utility at your own risk, This is for checking connectivity only, do not change any data through this utility.

hi, I already do the connection and visualization with third party software, I would like to do with hmg without depending on third party applications, I need connection examples and sqlserver database visualization with odbc or native

Re: mssql server 2012 express

Posted: Tue Apr 16, 2019 3:53 am
by bpd2000
Hi Jair Pinho,
FYI, Utility provided is compiled in Harbour
It is require to prepare similar application in HMG+Harbour
Connection can be done through HMG

Re: mssql server 2012 express

Posted: Tue Apr 16, 2019 11:52 am
by mol
Hi!
I don't know if it help you, few years ago I wrote application working with MS SQL:

Code: Select all

function 	SetDatabaseConnection
	
	do while .t.

		// sddodbc
		RDDSETDEFAULT( "SQLMIX" )
		SET( 4, "yyyy-mm-dd" )
		WAIT WINDOW "Trying to connect..." NOWAIT
		nConnection := RDDINFO( 1001, { "ODBC", cConStr }, 'SQLMIX' )
		WAIT CLEAR
		//msgbox("Connect: "+str(nConnection))
		If nConnection == 0
			MsgStop("Error with connection: " + cSQLBase)
			if MsgYesNo("Try to make new database: " + cSQLBase + "?")
				cConStr := "Driver={SQL Server};Server=" + cSQLSerwer + ";Database="+ "master" + ";Trusted_Connection=yes;Uid=" + cSQLUser + ";Pwd="+ cSQLPassword +";"
				nConnection := RDDINFO( 1001, { "ODBC", cConStr }, 'SQLMIX' )
				if nConnection == 0
					MsgStop("Error while making new DB: "+ cSQLBase)
					Release Window ALL
					Quit
				else
					if SQL_DowolnySQL("CREATE DATABASE " + cSQLBase)
						loop
					else
						MsgStop("Error while making new DB: "+ cSQLBase)
						quit
					endif
				endif
			else
				Release Window ALL
				Quit
			endif
		else
			exit
		Endif               	
	enddo
	// czy jest już tabela?
	aTables := SQL_GetColumn("information_schema.tables","Table_name","Table_name='PISMA'")
	if ascan(aTables, {|x| upper(x) == "PISMA"}) = 0
		SQL_CreateTables()
	endif
return

function SQL_DowolnySQL
	param cSQL
	local lOdp := .f.

	local xFormatDaty
	
	xFormatDaty := SET( _SET_DATEFORMAT, "yyyy-mm-dd" )
	lodp := RDDINFO(RDDI_EXECUTE, cSQL)
	SET( _SET_DATEFORMAT, xFormatDaty)	
 return lOdp

Re: mssql server 2012 express

Posted: Tue Apr 16, 2019 2:30 pm
by Ismach
Yo uso ADODB de winole y funciona de maravillas

Code: Select all

// Provider=SQLOLEDB; Data Source=A31ServerGenoa\dbMelloa;Initial Catalog=dbMelloa;User ID=genoa;Password=A13genoa;

// USUARIO
static ccUser  := "genoa"

// PASSWORD
static ccPass  := "A13genoa"

// NOMBRE DEL HOST + NOMBREDE LA BASE DE DATOS
static ccHost_NomBase  := "A31ServerGenoa\dbMelloa;Initial Catalog=dbMelloa;"

// PROVEEDOR DEL API CONNECTOR
static ccProvider  := "SQLOLEDB;"

en el main defino el objeto de conexion de dominio Publico

Code: Select all

PUBLIC oServer   AS OBJECT
y esta funcion

Code: Select all

FUNCTION Gus_ConectaSQLServer()

     Local ccConnector := "Provider=" + ccProvider + ";" + ;
                          "Data Source= " + ccHost_NomBase + ";" + ;
                          "User ID=" + ccUser + ";" + ;
                          "Password=" + ccPass + ";"
     // msginfo(ccConnector)
     oServer := TOLEAuto():New('ADODB.Connection')
     oServer:Open( ccConnector )

RETURN NIL

Re: mssql server 2012 express

Posted: Wed Apr 17, 2019 12:45 am
by jairpinho
mol wrote: Tue Apr 16, 2019 11:52 am Hi!
I don't know if it help you, few years ago I wrote application working with MS SQL:

Code: Select all

function 	SetDatabaseConnection
	
	do while .t.

		// sddodbc
		RDDSETDEFAULT( "SQLMIX" )
		SET( 4, "yyyy-mm-dd" )
		WAIT WINDOW "Trying to connect..." NOWAIT
		nConnection := RDDINFO( 1001, { "ODBC", cConStr }, 'SQLMIX' )
		WAIT CLEAR
		//msgbox("Connect: "+str(nConnection))
		If nConnection == 0
			MsgStop("Error with connection: " + cSQLBase)
			if MsgYesNo("Try to make new database: " + cSQLBase + "?")
				cConStr := "Driver={SQL Server};Server=" + cSQLSerwer + ";Database="+ "master" + ";Trusted_Connection=yes;Uid=" + cSQLUser + ";Pwd="+ cSQLPassword +";"
				nConnection := RDDINFO( 1001, { "ODBC", cConStr }, 'SQLMIX' )
				if nConnection == 0
					MsgStop("Error while making new DB: "+ cSQLBase)
					Release Window ALL
					Quit
				else
					if SQL_DowolnySQL("CREATE DATABASE " + cSQLBase)
						loop
					else
						MsgStop("Error while making new DB: "+ cSQLBase)
						quit
					endif
				endif
			else
				Release Window ALL
				Quit
			endif
		else
			exit
		Endif               	
	enddo
	// czy jest już tabela?
	aTables := SQL_GetColumn("information_schema.tables","Table_name","Table_name='PISMA'")
	if ascan(aTables, {|x| upper(x) == "PISMA"}) = 0
		SQL_CreateTables()
	endif
return

function SQL_DowolnySQL
	param cSQL
	local lOdp := .f.

	local xFormatDaty
	
	xFormatDaty := SET( _SET_DATEFORMAT, "yyyy-mm-dd" )
	lodp := RDDINFO(RDDI_EXECUTE, cSQL)
	SET( _SET_DATEFORMAT, xFormatDaty)	
 return lOdp
could i make an example in ide, because i test your example and nothing happens what lib should i use in ide libs =?

Re: mssql server 2012 express

Posted: Wed Apr 17, 2019 12:45 am
by jairpinho
Ismach wrote: Tue Apr 16, 2019 2:30 pm Yo uso ADODB de winole y funciona de maravillas

Code: Select all

// Provider=SQLOLEDB; Data Source=A31ServerGenoa\dbMelloa;Initial Catalog=dbMelloa;User ID=genoa;Password=A13genoa;

// USUARIO
static ccUser  := "genoa"

// PASSWORD
static ccPass  := "A13genoa"

// NOMBRE DEL HOST + NOMBREDE LA BASE DE DATOS
static ccHost_NomBase  := "A31ServerGenoa\dbMelloa;Initial Catalog=dbMelloa;"

// PROVEEDOR DEL API CONNECTOR
static ccProvider  := "SQLOLEDB;"

en el main defino el objeto de conexion de dominio Publico

Code: Select all

PUBLIC oServer   AS OBJECT
y esta funcion

Code: Select all

FUNCTION Gus_ConectaSQLServer()

     Local ccConnector := "Provider=" + ccProvider + ";" + ;
                          "Data Source= " + ccHost_NomBase + ";" + ;
                          "User ID=" + ccUser + ";" + ;
                          "Password=" + ccPass + ";"
     // msginfo(ccConnector)
     oServer := TOLEAuto():New('ADODB.Connection')
     oServer:Open( ccConnector )

RETURN NIL
could i make an example in ide, because i test your example and nothing happens what lib should i use in ide libs =?

Re: mssql server 2012 express

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

This an example I hope help you