MsSQL FreeTDS With Azure Connect

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
rzsistemas
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 21.04.2013, 18:21

MsSQL FreeTDS With Azure Connect

Post by rzsistemas »

I use a dbLib to conect with SQL server and FreeTDS_MsSQL-7.0. This is working so far.
But when I connect to azure i get the follow error:

DBError : [40508] : General SQL Server error: Check messages from the SQL Server
USE statement is not supported to switch between databases. Use a new connection to connect to a different database.

In microsoft I found https://msdn.microsoft.com/en-us/librar ... 36282.aspx

Transact-SQL statements

The Transact-SQL USE command is not currently supported for switching between databases. Establish a connection directly to the target database.

in ZDBCDbLib i Found
procedure TZDBLibConnection.Open;
var
LogMessage: RawByteString;
begin
if not Closed then
Exit;

InternalLogin;

LogMessage := 'USE '+ ConSettings^.Database;

---
How I can conect to azure database ?
guiwunsch
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 12.02.2021, 15:11

Re: MsSQL FreeTDS With Azure Connect

Post by guiwunsch »

Same here.
Does any one have connected on a SQL Server Azure Database with Zeos?

Thanks.
guiwunsch
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 12.02.2021, 15:11

Re: MsSQL FreeTDS With Azure Connect

Post by guiwunsch »

Same here.
Does any one have connected on a SQL Server Azure Database with Zeos?

Thanks.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: MsSQL FreeTDS With Azure Connect

Post by marsupilami »

Your best bet probably is to use Zeos 8.0 and OleDB. With FreeTDS somebody has to look into getting this to work. Unfortunately I don't have an Azure Database to test against.

The error probably is generated by the calls to dbuse in the dblib driver.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: MsSQL FreeTDS With Azure Connect

Post by marsupilami »

Note: Our current use of the freetds library most probably will not allow connecting to Azure SQL. For this to work we will have to set the database name in the LOGINREC structure. FreeTDS introduced the DBSETLDBNAME macro for this purpose. I created a feature request to track this:
https://sourceforge.net/p/zeoslib/internaltickets/29/
guiwunsch
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 12.02.2021, 15:11

Re: MsSQL FreeTDS With Azure Connect

Post by guiwunsch »

Hi.
Thank you for your support.
I've just tried to connect with Zeos 8.0 beta using OleDB but I guess that I couldn't setup the component to perform this connection. First of all I downloaded the driver at https://docs.microsoft.com/pt-br/sql/co ... rver-ver15 . Afer that, when I go to ODBC Data Sources on Windows I cant see the installed driver. Do you have a any tutorial to do this? I don't know too what I can fill in Protocol and HostName properties in ZConnection?

Thanks.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: MsSQL FreeTDS With Azure Connect

Post by marsupilami »

OleDB isn't ODBC. You will have to create a connection string for using OleDB. That connection string goes into the database property of TZConnection.
Could you please try what happens when you click on the small button with the "..." right next to the Database property? If all is well, a window should open that helps you in building the connection string. If it doesn't, choose ADO as the protocol. Click on "..." to build and test the connection string. Then use that connection string with OleDB.
guiwunsch
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 12.02.2021, 15:11

Re: MsSQL FreeTDS With Azure Connect

Post by guiwunsch »

Could you help me?

This error appears to me when I changed Connected propertyd to True:

Code: Select all

Project Project1.exe raised exception class EZSQLException with message 'SQL Error: OLEDB Error 
SQLState: 28000 Native Error: 0
Error message: Especificação de autorização inválida
Source: Microsoft OLE DB Provider for SQL Server
SQLServer details:  
Code: 0 Message: IID_IDBInitialize.Initialize'.
When I configure OLE DB via "..." on Database property the connection test works fine.

If I use "ado" on Protocol property using an OLE DB Datasource it appears to work OK!
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: MsSQL FreeTDS With Azure Connect

Post by marsupilami »

Hello,

I am sorry - I cannot help with that. I don't have access to an Azure database. If it works with ADO I suggest to keep using that for now.

Maybe it has to do with storing - or not storing user credentials in the connection string?

Best regards,

Jan
guiwunsch
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 12.02.2021, 15:11

Re: MsSQL FreeTDS With Azure Connect

Post by guiwunsch »

I'm just storing the credentials in the connnection string. If you want you can create an Azure SQL Server Database for 12 months for free (https://azure.microsoft.com/en-us/free/sql-database/) or I can share my database credentials with you.

Thanks.
Post Reply