Page 1 of 1

MsSQL FreeTDS With Azure Connect

Posted: 01.07.2015, 01:32
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 ?

Re: MsSQL FreeTDS With Azure Connect

Posted: 12.02.2021, 15:12
by guiwunsch
Same here.
Does any one have connected on a SQL Server Azure Database with Zeos?

Thanks.

Re: MsSQL FreeTDS With Azure Connect

Posted: 12.02.2021, 15:15
by guiwunsch
Same here.
Does any one have connected on a SQL Server Azure Database with Zeos?

Thanks.

Re: MsSQL FreeTDS With Azure Connect

Posted: 12.02.2021, 17:57
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.

Re: MsSQL FreeTDS With Azure Connect

Posted: 12.02.2021, 20:39
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/

Re: MsSQL FreeTDS With Azure Connect

Posted: 12.02.2021, 21:49
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.

Re: MsSQL FreeTDS With Azure Connect

Posted: 13.02.2021, 11:13
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.

Re: MsSQL FreeTDS With Azure Connect

Posted: 10.03.2021, 15:01
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!

Re: MsSQL FreeTDS With Azure Connect

Posted: 11.03.2021, 10:20
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

Re: MsSQL FreeTDS With Azure Connect

Posted: 15.03.2021, 15:58
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.