Page 1 of 1

Requirements for Connecting to MS SQL

PostPosted: Wed Jul 11, 2012 6:33 am
by cdmmaui
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 )

Re: Requirements for Connecting to MS SQL

PostPosted: Wed Jul 11, 2012 6:37 am
by Enrico Maria Giordano
This is the connectionstring I'm using:

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

EMG

Re: Requirements for Connecting to MS SQL

PostPosted: Wed Jul 11, 2012 7:01 am
by cdmmaui
Hi Enrico,

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

Re: Requirements for Connecting to MS SQL

PostPosted: Wed Jul 11, 2012 7:54 am
by Enrico Maria Giordano
Try also with

Code: Select all  Expand view
Data Source=ip address


EMG

Re: Requirements for Connecting to MS SQL

PostPosted: Wed Jul 11, 2012 8:07 am
by cdmmaui
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

Re: Requirements for Connecting to MS SQL

PostPosted: Wed Jul 11, 2012 8:10 am
by Enrico Maria Giordano
The error message is clear: you specified the wrong ip address or you don't have the rights to access the database.

EMG

Re: Requirements for Connecting to MS SQL

PostPosted: Wed Jul 11, 2012 8:23 am
by cdmmaui
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.