Requirements for Connecting to MS SQL

Requirements for Connecting to MS SQL

Postby cdmmaui » Wed Jul 11, 2012 6: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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Requirements for Connecting to MS SQL

Postby Enrico Maria Giordano » Wed Jul 11, 2012 6:37 am

This is the connectionstring I'm using:

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8704
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Requirements for Connecting to MS SQL

Postby cdmmaui » Wed Jul 11, 2012 7: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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong


Re: Requirements for Connecting to MS SQL

Postby cdmmaui » Wed Jul 11, 2012 8: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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Requirements for Connecting to MS SQL

Postby Enrico Maria Giordano » Wed Jul 11, 2012 8: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
User avatar
Enrico Maria Giordano
 
Posts: 8704
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Requirements for Connecting to MS SQL

Postby cdmmaui » Wed Jul 11, 2012 8: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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 19 guests