FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Requirements for Connecting to MS SQL
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Requirements for Connecting to MS SQL
Posted: Wed Jul 11, 2012 06:33 AM

Hello,

I have installed the following application on a Windows 7 64 bit workstation. The object is created OK, but fails at oSql:Open( cSql, cConnectString ). However, I am able to ping IP address.

I have the following versions of SQL installed on the workstation. Am I missing something?

  1. Microsoft SQL Server 2005 Compact Edition
  2. Microsoft SQL Server 2008 Native Client
  3. Microsoft SQL Server 2012 (64 Bit)
  4. Microsoft SQL Server 2012 Native Client
  5. Microsoft SQL Server Native Client

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

include "FiveWin.ch"

//----------------------------------------------------------------//
function Main()

local cConnectString := "" , ;
cSql := "" , ;
oSql , ;
oDlg , ;
oLbx

// Connecting to MS SQL Database
cConnectString:="Provider=SQLOLEDB;server=64.78.59.231;database=globallogistics;uid=cdmwoodlands;pwd=Alexander1209"

// Connection Object ====> oSql:=CreateObject("ADODB.Connection")
TRY
oSql:=CreateObject("ADODB.Recordset")
CATCH
MsgInfo("It seems that your PC does not have MDAC installed OR MDAC is corrupted.")
RETURN (.F.)
END
MsgInfo( "Object Created!")

// Set SQL string...
cSql := "SELECT * FROM support"
TRY
oSql:Open( cSql, cConnectString )
CATCH oError
MsgInfo("Failed to Connect to the Database")
RETURN .F.
END
MsgInfo( "Connected to Database" )

// Check for EOF...
IF oSql:eof
MsgInfo( "No Data Found" )
oSql:Close()
oSql:=NIL
RETURN (.F.)
ENDIF

// Move to first...
oSql:MoveFirst()

// Dialog...
DEFINE DIALOG oDlg FROM 1,1 TO 35,104 TITLE "Support Ticket"

@00,00 LISTBOX oLbx FIELDS ;
oSql:Fields( "company_name" ):Value , ;
oSql:Fields( "contact_first" ):Value , ;
oSql:Fields( "contact_last" ):Value , ;
oSql:Fields( "contact_phone" ):Value , ;
oSql:Fields( "contact_email" ):Value , ;
oSql:Fields( "system" ):Value , ;
oSql:Fields( "module" ):Value , ;
oSql:Fields( "adddate" ):Value , ;
oSql:Fields( "addtime" ):Value , ;
oSql:Fields( "adduser" ):Value ;
SIZES 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 ;
HEADERS "Company", "First Name", "Last Name", "Telephone", "E-mail", "System", "Module", "Add Date", "Add Time", "Add User" ;
OF oDlg

oLbx:bLogicLen = { || oSql:RecordCount }
oLbx:bGoTop = { || oSql:MoveFirst() }
oLbx:bGoBottom = { || oSql:MoveLast() }
oLbx:bSkip = { | nSkip | Skipper( oSql, nSkip ) }
oLbx:cAlias = "ARRAY1"

ACTIVATE DIALOG oDlg ON INIT ( oDlg:SetControl( oLbx ), Sysrefresh() )

// Disconnecting
oSql:Close()
oSql:=NIL

RETURN (.T.)

//-------------------------------
STATIC FUNCTION SKIPPER( oRsx, nSkip )

LOCAL nRec := oRsx:AbsolutePosition

oRsx:Move( nSkip )

IF oRsx:EOF; oRsx:MoveLast(); ENDIF
IF oRsx:BOF; oRsx:MoveFirst(); ENDIF

RETURN( oRsx:AbsolutePosition - nRec )

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Requirements for Connecting to MS SQL
Posted: Wed Jul 11, 2012 06:37 AM

This is the connectionstring I'm using:

Provider=sqloledb;Data Source=...;User Id=...;Password=...

EMG

Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: Requirements for Connecting to MS SQL
Posted: Wed Jul 11, 2012 07:01 AM

Hi Enrico,

Thank you, I changed to User Id= and Password= and still got error

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Requirements for Connecting to MS SQL
Posted: Wed Jul 11, 2012 07:54 AM
Try also with

Code (fw): Select all Collapse
Data Source=ip address


EMG
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: Requirements for Connecting to MS SQL
Posted: Wed Jul 11, 2012 08:07 AM

Hi Enrico,

I am getting the following error for connection string Provider=SQLOLEDB;Data Source=64.78.59.231;User ID=xxxx;Password=xxxx

[DBNETLIB][ConnectionOpen(Connect()).]SQL Server does not exist or access denied
Microsoft OLE DB Provider for SQL Server

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Requirements for Connecting to MS SQL
Posted: Wed Jul 11, 2012 08:10 AM

The error message is clear: you specified the wrong ip address or you don't have the rights to access the database.

EMG

Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: Requirements for Connecting to MS SQL
Posted: Wed Jul 11, 2012 08:23 AM

Hi Enrico,

Correct, but I am able to connect from my workstation without a problem but when I installed on another workstation I got the error message.

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com

Continue the discussion