 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Keith Guest
|
Posted: Wed Mar 09, 2005 8:41 pm Post subject: Getting Database Owner after connected |
|
|
Anyone know how I can get the database owner in MS SQL?
Looking for the easiest way. Prefer no low level table calls, but it may be
necessary.
I tried the following in Enterprise Manager and it returns "DBO". Which is
correct.
When I tried it in Delphi, the query executes, but no fields / no data is
returned.
SELECT su.name FROM SysUsers su WHERE UID =
(
select MemberUID from SysMembers where GroupUID =
(select UID from SysUsers where name = 'db_owner')
)
Any ideas?
Thank you.
|
|
| Back to top |
|
 |
Kevin Frevert Guest
|
Posted: Thu Mar 10, 2005 6:14 pm Post subject: Re: Getting Database Owner after connected |
|
|
Keith,
How are you running the query in Delphi? BDE or ADO?
krf
"Keith" <kicks23 (AT) verizon (DOT) net> wrote
| Quote: | Anyone know how I can get the database owner in MS SQL?
Looking for the easiest way. Prefer no low level table calls, but it may
be
necessary.
I tried the following in Enterprise Manager and it returns "DBO". Which
is
correct.
When I tried it in Delphi, the query executes, but no fields / no data is
returned.
SELECT su.name FROM SysUsers su WHERE UID =
(
select MemberUID from SysMembers where GroupUID =
(select UID from SysUsers where name = 'db_owner')
)
Any ideas?
Thank you.
|
|
|
| Back to top |
|
 |
Keith Guest
|
Posted: Thu Mar 10, 2005 7:26 pm Post subject: Re: Getting Database Owner after connected |
|
|
My original post (no fields returned) below was with using BDE.
I then tried ADO and getting mixed results.
Sometimes I get the db owner, sometimes it fails because "Invalid connection
string attribute" on the ADOConnection1.Open;
the connection string I put together is like this...
User ID=testuser;Password=testpass;DSN=TestAlias
Like I said, the above connection string works for some users & not others.
Their rites seem to be identical.
Can this be done using BDE? If not, that's ok.
But, can you suggest how to consistently get the ADO connection to work when
all I have are the USER, PASS, and DB alias?
Thanks.
"Kevin Frevert" <drinkingdietcoke (AT) work (DOT) com> wrote
| Quote: | Keith,
How are you running the query in Delphi? BDE or ADO?
krf
"Keith" <kicks23 (AT) verizon (DOT) net> wrote in message
news:422f5f66$1 (AT) newsgroups (DOT) borland.com...
Anyone know how I can get the database owner in MS SQL?
Looking for the easiest way. Prefer no low level table calls, but it
may
be
necessary.
I tried the following in Enterprise Manager and it returns "DBO". Which
is
correct.
When I tried it in Delphi, the query executes, but no fields / no data
is
returned.
SELECT su.name FROM SysUsers su WHERE UID =
(
select MemberUID from SysMembers where GroupUID =
(select UID from SysUsers where name = 'db_owner')
)
Any ideas?
Thank you.
|
|
|
| Back to top |
|
 |
Kevin Frevert Guest
|
Posted: Thu Mar 10, 2005 8:52 pm Post subject: Re: Getting Database Owner after connected |
|
|
Keith,
Microsoft didn't update their DBLib (which the BDE uses) for MSSQL 7/2000,
so the new datatypes used in the system tables aren't 'officially'
supported. If you have to use the BDE you can cast the values into
datatypes the DBLib/BDE understands like...
SELECT CAST(su.name as varchar(128)) [db_owner]
FROM SysUsers su
WHERE UID =
(
select MemberUID from SysMembers where GroupUID =
(select UID from SysUsers where name = 'db_owner')
)
ADO (OLE-DB) is the Microsoft "preferred" way to connect to MSSQL (I guess now it's
ADO.Net, but let's not go there yet . Make sure you are using the native
SQL Server connection (not ODBC) so your connection string will/should look
something like...
Provider=SQLOLEDB.1;Persist Security Info=False;Initial
Catalog=YourDatabase;Data Source=YourSQLServer;User ID=YourUserID
Good luck,
krf
"Keith" <kicks23 (AT) verizon (DOT) net> wrote
| Quote: | My original post (no fields returned) below was with using BDE.
I then tried ADO and getting mixed results.
Sometimes I get the db owner, sometimes it fails because "Invalid
connection
string attribute" on the ADOConnection1.Open;
the connection string I put together is like this...
User ID=testuser;Password=testpass;DSN=TestAlias
Like I said, the above connection string works for some users & not
others.
Their rites seem to be identical.
Can this be done using BDE? If not, that's ok.
But, can you suggest how to consistently get the ADO connection to work
when
all I have are the USER, PASS, and DB alias?
Thanks.
"Kevin Frevert" <drinkingdietcoke (AT) work (DOT) com> wrote in message
news:42308e81$1 (AT) newsgroups (DOT) borland.com...
Keith,
How are you running the query in Delphi? BDE or ADO?
krf
"Keith" <kicks23 (AT) verizon (DOT) net> wrote in message
news:422f5f66$1 (AT) newsgroups (DOT) borland.com...
Anyone know how I can get the database owner in MS SQL?
Looking for the easiest way. Prefer no low level table calls, but it
may
be
necessary.
I tried the following in Enterprise Manager and it returns "DBO".
Which
is
correct.
When I tried it in Delphi, the query executes, but no fields / no data
is
returned.
SELECT su.name FROM SysUsers su WHERE UID =
(
select MemberUID from SysMembers where GroupUID =
(select UID from SysUsers where name = 'db_owner')
)
Any ideas?
Thank you.
|
|
|
| Back to top |
|
 |
Keith Guest
|
Posted: Thu Mar 10, 2005 11:05 pm Post subject: Re: Getting Database Owner after connected |
|
|
Kevin,
Thanks for the help. Turns out that I need the Table Owner, not the DB
owner.
Your suggestion about casting the field + the SQL from another forum led me
to the following...
SELECT CAST(TABLE_SCHEMA as varchar(128))
FROM INFORMATION_SCHEMA.TABLES
WHERE (TABLE_NAME = :MyTable)
So, I can use the BDE (which makes it easier for now) & get what I needed.
Again, thanks for the help.
Keith
PS In case you're bored...
We support all (well, just about all) ODBC compliant databases. So, I will
need to get the Table Owner for DB2, Sybase, Sybase SQL Server, etc. Know a
good place to look for the syntax for these other DB types?
"Kevin Frevert" <drinkingdietcoke (AT) work (DOT) com> wrote
| Quote: | Keith,
Microsoft didn't update their DBLib (which the BDE uses) for MSSQL
7/2000,
so the new datatypes used in the system tables aren't 'officially'
supported. If you have to use the BDE you can cast the values into
datatypes the DBLib/BDE understands like...
SELECT CAST(su.name as varchar(128)) [db_owner]
FROM SysUsers su
WHERE UID =
(
select MemberUID from SysMembers where GroupUID =
(select UID from SysUsers where name = 'db_owner')
)
ADO (OLE-DB) is the Microsoft "preferred" way to connect to MSSQL (I guess now
it's
ADO.Net, but let's not go there yet . Make sure you are using the
native
SQL Server connection (not ODBC) so your connection string will/should
look
something like...
Provider=SQLOLEDB.1;Persist Security Info=False;Initial
Catalog=YourDatabase;Data Source=YourSQLServer;User ID=YourUserID
Good luck,
krf
"Keith" <kicks23 (AT) verizon (DOT) net> wrote in message
news:42309f57$1 (AT) newsgroups (DOT) borland.com...
My original post (no fields returned) below was with using BDE.
I then tried ADO and getting mixed results.
Sometimes I get the db owner, sometimes it fails because "Invalid
connection
string attribute" on the ADOConnection1.Open;
the connection string I put together is like this...
User ID=testuser;Password=testpass;DSN=TestAlias
Like I said, the above connection string works for some users & not
others.
Their rites seem to be identical.
Can this be done using BDE? If not, that's ok.
But, can you suggest how to consistently get the ADO connection to work
when
all I have are the USER, PASS, and DB alias?
Thanks.
"Kevin Frevert" <drinkingdietcoke (AT) work (DOT) com> wrote in message
news:42308e81$1 (AT) newsgroups (DOT) borland.com...
Keith,
How are you running the query in Delphi? BDE or ADO?
krf
"Keith" <kicks23 (AT) verizon (DOT) net> wrote in message
news:422f5f66$1 (AT) newsgroups (DOT) borland.com...
Anyone know how I can get the database owner in MS SQL?
Looking for the easiest way. Prefer no low level table calls, but
it
may
be
necessary.
I tried the following in Enterprise Manager and it returns "DBO".
Which
is
correct.
When I tried it in Delphi, the query executes, but no fields / no
data
is
returned.
SELECT su.name FROM SysUsers su WHERE UID =
(
select MemberUID from SysMembers where GroupUID =
(select UID from SysUsers where name = 'db_owner')
)
Any ideas?
Thank you.
|
|
|
| Back to top |
|
 |
Kevin Frevert Guest
|
Posted: Fri Mar 11, 2005 1:45 pm Post subject: Re: Getting Database Owner after connected |
|
|
"Keith" <kicks23 (AT) verizon (DOT) net> wrote
| Quote: | Keith
PS In case you're bored...
We support all (well, just about all) ODBC compliant databases. So, I
will
need to get the Table Owner for DB2, Sybase, Sybase SQL Server, etc. Know
a
good place to look for the syntax for these other DB types?
|
Definitely not bored. I've got projected projects scheduled for the next
two years, I barly have time to read these groups I'm afraid I don't
know much about those DBs, but I would assume they all have similar
mechanisms for retrieving that kind of information.
Good luck,
krf
|
|
| Back to top |
|
 |
Keith Guest
|
Posted: Fri Mar 11, 2005 4:19 pm Post subject: Re: Getting Database Owner after connected |
|
|
Yeah, that's what I figure.
I'll have to keep looking around for the syntax specific SQL for each of
those database's.
Thanks again for the help. Good luck on your projects.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|