Amigos, algún código lib o dll para acceder a MSSQL y poder leer datos y actualizaciones??, probe los demos pero no van,,,,
Salu2
Willi
Amigos, algún código lib o dll para acceder a MSSQL y poder leer datos y actualizaciones??, probe los demos pero no van,,,,
Salu2
Willi
// Sql Server test program
#Include "FiveWin.ch"
//----------------------------
Func Main()
Local xProvider,xSource,xCatalog,xUserId,xPassword,xConnect
Local oRs,cSql,oErr,Saying
Public oCn
xPROVIDER := "SQLOLEDB" // oledb provider
xSOURCE := "RICKLIPKIN-PC\SQLEXPRESS" // sql server name
xCATALOG := "TRAVEL" // sql server database
xUSERID := "xxxxxxx"
xPASSWORD := "xxxxxxx"
xConnect := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD // connection string
Try
oCn := CREATEOBJECT( "ADODB.Connection" )
Catch
MsgInfo( "Could not create the ADO object for connection")
Return(.f.)
End Try
TRY
oCn:Open( xConnect ) // connection object
CATCH oErr
MsgInfo( "Could not open a Connection to Database "+xSource )
RETURN(.F.)
END TRY
oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType := 1 // opendkeyset
oRs:CursorLocation := 3 // local cache
oRs:LockType := 3 // lockoportunistic
cSQL := "SELECT * From [Staff]"
TRY
oRs:Open( cSQL, oCn )
CATCH oErr
Saying := "Error in Opening STAFF table to"+chr(10)
Saying += "Import Legacy Data"+chr(10)
MsgInfo( Saying )
oCn:Close()
RETURN(.F.)
END TRY
xBrowse( oRs )
oRs:Close()
oCn:Close()
Return(.t.)Error in "oCn: Open (xConnect)" something must be wrong, as would do to connect to the IP, my data server has the IP 192.168.1.99 or http:serverdat.net?
regards
Willi
You can use the IP address of your server or the Server name. Make sure your userid, password and database name are correct.
You can use the Microsoft SQL Management Studio that comes with Sql Server to login to your database to test your connection credentials.
Rick Lipkin
Hola Rick , le hago una pregunta. usted seria tan amable si posee una conexión de esta forma para MySql. ya que veo esta mas avanzado que yo.
Juan
Take another look at my sample .. Ms Sql Server uses the built in Ole Provider called SqlOleDb which is on every Windows machine from Xp thru Windows 8.
There is nothing to configure or any setup needed on the workstation. That is what makes connecting to Ms Sql Server so nice. You do not need to distribute any Ole Client, run-time or Odbc to the desktop..
All you need to do is make sure your connection credentials are setup properly on your Sql Server and use ADO to manage and manipulate the data.
Rick Lipkin