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:

mssql server 2012 express

Post 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?
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: mssql server 2012 express

Post 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.
Attachments
view_sqldatabase.rar
(1.23 MiB) Downloaded 335 times
BPD
Convert Dream into Reality through HMG
jorge.posadas
Posts: 172
Joined: Mon May 19, 2014 7:43 pm
DBs Used: DBF, SQLite, MS-SQL, ACCESS, MariaDB (en proceso)
Location: Morelia, Mich. México
Contact:

Re: mssql server 2012 express

Post 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
Cordialmente

POSADAS SOFTWARE
Jorge Posadas Ch.
Programador independiente
Morelia, Mich.
M é x i c o .
Movil +52 44 3734 1858
SKYPE: jorge.posadasch
Email: posoft@gmx.com
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 »

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
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: mssql server 2012 express

Post 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
BPD
Convert Dream into Reality through HMG
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: mssql server 2012 express

Post 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
User avatar
Ismach
Posts: 161
Joined: Wed Nov 28, 2012 5:55 pm
DBs Used: DBF, mySQL, Mariadb, postgreSQL, Oracle, Db2, Interbase, Firebird, and SQLite
Location: Buenos Aires - Argentina

Re: mssql server 2012 express

Post 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
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 »

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 =?
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
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 »

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 =?
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
jorge.posadas
Posts: 172
Joined: Mon May 19, 2014 7:43 pm
DBs Used: DBF, SQLite, MS-SQL, ACCESS, MariaDB (en proceso)
Location: Morelia, Mich. México
Contact:

Re: mssql server 2012 express

Post by jorge.posadas »

jairpinho

This an example I hope help you
Attachments
Tracking.zip
HMG + ADO + MS-SQL
(1.71 MiB) Downloaded 332 times
Cordialmente

POSADAS SOFTWARE
Jorge Posadas Ch.
Programador independiente
Morelia, Mich.
M é x i c o .
Movil +52 44 3734 1858
SKYPE: jorge.posadasch
Email: posoft@gmx.com
Post Reply