Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 1 Woche, 2 Tagen
Letzter Beitrag:
vor 3 Tagen, 6 Stunden
Beteiligte Autoren:
Joris, steve erts, Peter Holemans, Sivaprakash

WD21 : How to connect with MS SQL database over the network?

Startbeitrag von Joris am 16.05.2017 13: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

Antworten:

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

von Peter Holemans - am 16.05.2017 14:08
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

von Sivaprakash - am 18.05.2017 13:30
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)



von Joris - am 22.05.2017 09:37
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

von steve erts - am 22.05.2017 17:58
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.