PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → WD21 : How to connect with MS SQL database over the network?
WD21 : How to connect with MS SQL database over the network?
Débuté par Joris, 16 mai 2017 15:49 - 6 réponses
Posté le 16 mai 2017 - 15:49
Hi,

I need to make a connection with an SQL database to load some data from another software into our Windev application (that is using Hyperfile).
I managed to do this by using the SQLConnect() command, SQLFirst(), SQLNext() etc...
This is working fine on the server (where the SQL database is located) but not on workstations.

I'm using this command :

MyConnection is int = SQLConnect("SBS2011\PFD","MyLogin","MyPassword","PFD","OLEDB",hOledbSQLServer)
SQL Server 2008 R2
SBS2011 is the name of the server
PFD is the name of the database

Many thanks,

Joris
Posté le 16 mai 2017 - 16:08
Hi Joris,

I'ld use oleDB for SQL Server in this case instead of ODBC...
You'll make your life a lot easier.

Cheers,

Peter Holemans
Membre enregistré
282 messages
Popularité : +1 (1 vote)
Posté le 16 mai 2017 - 16:38
Hi Joris,

is 1433 port open on your SBS2011 ??

--
Christophe Charron
Posté le 16 mai 2017 - 16:45
John,
- In SQL server manager allow remote connections
- In SQL configuration manager allow the tcp-ip protocol instead of pipes
- SQL express uses dynamic ports. Google for configure firewall mssql express.

Succes

Walter
Posté le 18 mai 2017 - 15:30
I could connect to any MS Sql Server in my network with the following connection parameters.

DataBaseConnection is Connection

DataBaseConnection..Provider = hOledbSQLServer
DataBaseConnection..User = INIRead("Database","LogId", "", "INI FileName")
DataBaseConnection..Password = INIRead("Database", "Logpassword","", "INI FileName")
DataBaseConnection..Server = INIRead("Database", "ServerName","", "INI FileName")
DataBaseConnection..Database = INIRead("Database", "Database", "", "INI FileName")
//DataBaseConnection..Access = hORead

IF HOpenConnection(DataBaseConnection) = False THEN
Info(HErrorInfo)
EndProgram(False)
END

IF HChangeConnection("*", DataBaseConnection) = False THEN
Info(HErrorInfo)
EndProgram(False)
END

Hope by having relevant data in the ini file, you could also connect.

Happiness Always
BKR Sivaprakash
Posté le 22 mai 2017 - 11:37
Thank you both for your answers. I am able to connect with the server and get some data with the code below.

MyConnection is Connection MyQuery is Data Source MyConnection..Provider = hOledbSQLServer MyConnection..User = "MyLogin" MyConnection..Password = "MyPassword" MyConnection..Server = "SBS2011\PFD" MyConnection..Database = "PFD" MyConnection..Access = hORead IF NOT HOpenConnection(MyConnection) THEN Error("The connection to the data source failed." + CR + HErrorInfo(hErrFullDetails)) RETURN END IF NOT HExecuteSQLQuery(MyQuery,MyConnection,hQueryWithoutCorrection,"select DESCRIPTION from TR031") THEN Error(HErrorInfo) RETURN END FOR ALL MyQuery Trace(MyQuery.DESCRIPTION) END HCloseConnection(MyConnection)
Posté le 22 mai 2017 - 19:58
I created a little application using hyperfile to store my SQL server DB connections info in (and to encrypt them) and also used this to create a menu system to allow me to pick which DB to mount to.

steve