FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour tdsn.ch for tdsn class
Posts: 193
Joined: Wed Apr 04, 2007 06:54 AM
tdsn.ch for tdsn class
Posted: Tue May 25, 2010 06:51 AM

hi,
can someone post to me the file TDSN.CH for the class tdsn?
(to automatically create a dsn in ODBC)

thanks in advance
marzio

Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: tdsn.ch for tdsn class
Posted: Tue May 25, 2010 08:10 PM
I was using a DSN entry but since I found a way to access ODBC without having a DSN entry, it has been less I have to do at each workstation.

Check out this http://www.w3schools.com/ado/ado_connect.asp

We have a new system using Progress so here is my sample Progress connect string:
Code (fw): Select all Collapse
cConnectString := "DRIVER={Progress OpenEdge 10.2A Driver};host=trg-triniumdb;uid=MyUserId; password=MyPassWord; port=12000;db=us_live;"
oRecordSet := CreateObject( "ADODB.Recordset" )
cSql := [SELECT * FROM MyTable]
? 'Connect String = '+cConnectString
? 'Sql String = '+cSql
oRecordSet:Open( cSql, cConnectString, 0, 1 )


Here is an Access connect string
Code (fw): Select all Collapse
   ::cDriver         := [{"Driver={Microsoft Access Driver (*.mdb)}]
   ::cHost           := []
   ::cUserId         := []
   ::cPassword       := []
   ::cDatabase       := [\\Trg210\webcenter\Database\webcenter40.mdb]
   ::cConnectString  := [DRIVER=]+::cDriver+[;]+ ;
      [dbq=]+::cDatabase+[;]
Posts: 193
Joined: Wed Apr 04, 2007 06:54 AM
Re: tdsn.ch for tdsn class
Posted: Wed May 26, 2010 09:58 AM

thanks for yuor reply.

I also use ado to connect to sql dbase,
but i have an old program with odbc connection.
before to convert the old program to ado instructions,
i would like to make the automatic creation of the odbc dsn.

ciao, marzio

Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: tdsn.ch for tdsn class
Posted: Wed May 26, 2010 01:39 PM
You can use ODBC WITHOUT creating DSN entry.
Here is a website that has many DSN-Less and other connection strings. They use ASP but easily converted to xHarbour.
http://www.codemaker.co.uk/it/tips/ado_conn.htm
Here is another
http://www.dofactory.com/Connect/Connect.aspx#_self2

for example: to connect to SQL server
Code (fw): Select all Collapse
oConn.Open "Driver={SQL Server};" & _ 
           "Server=MyServerName;" & _
           "Database=myDatabaseName;" & _
           "Uid=myUsername;" & _
           "Pwd=myPassword"
Or in xHarbour
   ::cDriver         := [{SQL Server}]
   ::cServer         := [MyServerName]
   ::cUserId         := [myUsername]
   ::cPassword       := [myPassword]
   ::cDatabase       := [\\Trg210\webcenter\Database\webcenter40.mdb]
   ::cConnectString  := [Driver=]+::cDriver+[;]+ ;
      [Server=]+::cServer+[;]+;
      [Database=]+::cDatabase+[;]+;
      [Uid=]+::cUserId+[;]+;
      [Pwd=]+::cPassword+[;]

Continue the discussion