views:

100

answers:

1

My Delphi application connects to a SQL Server Database through BDE.
In the process, my application queries SP_Who stored procedure to get the DbName column Value. But now I want to connect my application through ODBC to the SQL Server database.

I'm using the SQL Server Native client driver for this, but when my application queries SP_Who but the procedure does not return the DBName Column. Why is this? How can I get the value of DBName in this case? Is there any other procedure to obtain the DBName column value.

+2  A: 

You can obtain the database name using:

SELECT DB_NAME()

Do you get the DBName column running sp_who2 ?

Mitch Wheat
No I dont Ge DBName Column running sp_who2 either. The Select DB_NAME() dosent work too. It returns a blank column.
SK9
@SK9: sounds like it might be permissions related.
Mitch Wheat
@SK9: what identity and role are in running under?
Mitch Wheat
@SK9: SELECT DB_NAME() *has* to return a value. You always have a database context, even if it's master. Do you get any rows back from sp_who? Try SELECT @@SERVERNAME
gbn
I dont think this is a problem with the Databse rights or permissons, coz when I connect to the sane Database using BDE alias all the above commands Work. It seems they only dont give any value, when i connect trough the ODBC Connection. Am i missing some settings in creating the ODBC connection.
SK9
some how still when i use ODBC Sql server native client i dont get the DBname when i query sp_who. Infact i dont get the loginame field when i query the sys.sysprocesses. But I do get the DBID field which i used in this situation. This is a mere workaround to get my application up and running.
SK9