Microsoft SQL via ODBC? how to connect?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Microsoft SQL via ODBC? how to connect?

Post by mol »

Hi guys! I'm back after few months of absence...
I'm sorry that I couldn't work over new HMG4 :(

Now, I have big problem - I need to port one of my .dbf application to microsoft sql server, but I don't know, how to connect to database.
I'm trying something like that:

Code: Select all

	   nConnection := RDDINFO( 1001,{"ODBC", "Provider=SQLNCLI;Server=3K3877\KORESPONDENCJA;Database=test1; Trusted_Connection=yes;"})

Can sb. help me?
Many thanks, Marek
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Microsoft SQL via ODBC? how to connect?

Post by l3whmg »

Hi Marek,
I hope this is helpfull for you: in Harbour distribution "contrib\rddsql\sddodbc".
Best regards
Luigi from Italy
www.L3W.it
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Microsoft SQL via ODBC? how to connect?

Post by l3whmg »

Hi Marek,
in alternative this one "contrib\hbodbc".
I remember (but I'm not sure, I'm sorry) problem with ODBC low level code.
Bye
Luigi from Italy
www.L3W.it
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Microsoft SQL via ODBC? how to connect?

Post by mol »

Thanks Luigi for your quick answer, but these samples don't applicable MS SQL...

I've used this code:

Code: Select all

	   ? nConnection := RDDINFO( 1001, { "ODBC", "Driver={SQL Server};Server=3K3877\insertgt;Database=test1;Trusted_Connection=yes;Uid=sa;Pwd=;" }, 'SQLMIX' )
where 3K3877 is the name of my computer
InsertGT is the name of sql serve instance,
test1 is the name of database
and it connects!
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Microsoft SQL via ODBC? how to connect?

Post by l3whmg »

Hi Marek,
I'm sorry, but ODBC it's ODBC :?:
I can connect a MySql database with

Code: Select all

RDDSETDEFAULT( "SQLMIX" )
nConn := RDDINFO( RDDI_CONNECT, { "ODBC", "Server=servername;Driver={MySQL ODBC 5.1 Driver}; dsn=;User=test;Password=test;Database=test;" } )
or MDb

Code: Select all

RDDSETDEFAULT( "SQLMIX" )
nConn := RDDINFO( RDDI_CONNECT, { "ODBC", "DBQ=path\test.mdb;Driver={Microsoft Access Driver (*.mdb)} )
When you change driver and params (see MySql), you can connect Ms SQL...or not :?:

Perhaps I don't understand your problem :oops:
Luigi from Italy
www.L3W.it
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Microsoft SQL via ODBC? how to connect?

Post by l3whmg »

Hi,
the connection string was the problem? See http://www.connectionstrings.com
Ciao.
Luigi from Italy
www.L3W.it
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Microsoft SQL via ODBC? how to connect?

Post by mol »

Thanks, Luigi.
I've connected to database... I have no experience with any SQL database. Maybe I can't write about my problem well?
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Microsoft SQL via ODBC? how to connect?

Post by l3whmg »

Hi Marek,
I'm sorry I don't understood if problem was the connection string or about (specific) syntax or general ODBC usage :mrgreen: Sometime ago I tried ADODB but I don't find in new Harbour distribution.
Little question: why do you prefer "sddodbc" instead "hbodbc" ? Do you think it's possible to write (without any differences) program for M$Sql and Dbf (and MySql and PostGreSql) databases ? Personally, I found very good PostGreSql (recordlock), but I write different code (for the same program) to get/write data.
Bye
Luigi from Italy
www.L3W.it
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Microsoft SQL via ODBC? how to connect?

Post by mol »

Where can I find working sample with writing records to database?
HB contrib contains only example with reading....
Marek
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Microsoft SQL via ODBC? how to connect?

Post by l3whmg »

Hi Marek,
I'm sorry, I lost the source (but was with AdoDb) with example and I'm very surprised to know there isn't a write example in Harbour :o Question: all Harbour packages? Perhaps in old Hrb 1?
Now I have only example with PostGreSql.
Luigi from Italy
www.L3W.it
Post Reply