Hyphen in DB Name

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
xnadeem
Posts: 4
Joined: Tue 09 Jul 2019 12:11

Hyphen in DB Name

Post by xnadeem » Tue 09 Jul 2019 12:52

Hi,

I am facing an issue where I am trying to execute a stored procedure with no parameters and the Database name has got a hyphen in it. The Stored procedure does not execute and there is an SQL exception complaining about invalid character "-" in the query

Drilling down the DevArt code I have seen that the issue is in function "GetSqlForSysProcedureParameters"

The query thats being fired is trying to get the parameters but having DB name with hyphen and hence its failing. I am guessing it should simply amend the db name by adding "[" and "]"

Can this issue be looked at please

Stellar
Devart Team
Posts: 278
Joined: Tue 03 Oct 2017 11:00

Re: Hyphen in DB Name

Post by Stellar » Wed 10 Jul 2019 07:46

Please try to set the UseQuoteChar parameter to True in the connection settings. For example:

SQLConnection1.Params.Values['UseQuoteChar'] := 'True';

xnadeem
Posts: 4
Joined: Tue 09 Jul 2019 12:11

Re: Hyphen in DB Name

Post by xnadeem » Mon 15 Jul 2019 10:41

Hi,

I am using below code. As recommended setting 'UseQuoteChar' to true didn't work. The issue is the same as described in original post function "GetSqlForSysProcedureParameters" has the SQL query which throws SQL exception as DB is passed with a hyphen.

So If DB name is "N-CFG" it creates parameters as "N-CFG.dbo" which is incorrect. It should provided as [N-CFG].dbo

Please let me know if there is a workaround for this

Cheers

SQLDB := TSQLConnection.Create(nil);
SQLDB.LoginPrompt := False;
SQLDB.ConnectionName := 'MSSQLConnection';
SQLDB.DriverName := 'DevartSQLServer';
SQLDB.GetDriverFunc := 'getSQLDriverSQLServer';
SQLDB.LibraryName := 'dbexpsda40.dll';
SQLDB.VendorLib := 'sqlncli11';

SQLDB.Params.Values['UseQuoteChar'] := 'True';

SQLDB.Params.Values['Database'] := dbname;
SQLDB.Params.Values['User_name'] := username;
SQLDB.Params.Values['Password'] := password;
SQLDB.Params.Values['Hostname'] := hostname;
Last edited by xnadeem on Tue 16 Jul 2019 09:11, edited 1 time in total.

Stellar
Devart Team
Posts: 278
Joined: Tue 03 Oct 2017 11:00

Re: Hyphen in DB Name

Post by Stellar » Tue 16 Jul 2019 08:59

Unfortunately, we can't reproduce the issue. To investigate this behavior of dbExpress driver for SQL Server, please compose a small sample demonstrating the issue and send it to us, including database object creation scripts.
You can send the sample by using the contact form at our site: devart.com/company/contactform.html

Also, please specify the version of dbExpress driver for SQL Server you are using.

xnadeem
Posts: 4
Joined: Tue 09 Jul 2019 12:11

Re: Hyphen in DB Name

Post by xnadeem » Tue 16 Jul 2019 09:13

Hi,

to reproducer this you need to have a stored procedure with no parameters and DB name should have hyphen. Only then executing this stored procedure will recreate the issue. I hope you are doing the same

Cheers

Also will be providing you the code in question

Stellar
Devart Team
Posts: 278
Joined: Tue 03 Oct 2017 11:00

Re: Hyphen in DB Name

Post by Stellar » Thu 18 Jul 2019 08:52

Thank you for the information. We have fixed the issue, and the fix will be included in the next dbExpress driver for SQL Server build.

xnadeem
Posts: 4
Joined: Tue 09 Jul 2019 12:11

Re: Hyphen in DB Name

Post by xnadeem » Thu 18 Jul 2019 09:03

Any Idea when this new build will be available Please?

Stellar
Devart Team
Posts: 278
Joined: Tue 03 Oct 2017 11:00

Re: Hyphen in DB Name

Post by Stellar » Thu 18 Jul 2019 12:55

We can provide you with a nightly build of dbExpress driver for SQL Server Trial Edition with the latest fixes. Please send us a corresponding request via the e-support form on our website (devart.com the "Support"\"Request Support" menu)

Post Reply