Database Table Names

Hi,

I hope someone can help me out with this.

I have a database (say, a MS SQL Server DB).  I do a Table.GetTableNames on it and I'm provided with a list of times.  I'm also given the owner of the table (example, dbo.MyTable).

My question is - how can I remove the owner (keeping in mind that the owner name could have more or less than three characters).  And I don't want to manually delete the owner name from the table name.

There MUST be a way of returning just the table name.  I don't mind how it's done - except it MUST be doing using the BDE.

Thanks in advance.

Stuart
LVL 6
Stuart_JohnsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ITugayCommented:
Hi Stuart Johnson,
may be something like this:

procedure GetTableNames(DD: TDatabase; List: TStrings; SystemTables: Boolean = False);
var
  L: TStringList;
  I: Integer;
begin
  L := TStringList.Create;
  DD.GetTableNames(L, SystemTables);
  for I := 0 to L.Count - 1 do
    if Pos('.', L[I]) > 0 then
      L[I] := Copy(L[I], Pos('.', L[I]) + 1, 1000);
  List.Assign(L);
  L.Free;
end;
0
Mohammed NasmanSoftware DeveloperCommented:
Hello

  Try to return the tables name using SQL statement

  SELECT name FROM sysobjects where xtype = 'U'

I'm not sure if the it will return the tables owner or not, sorry I don't have SQL server now to test

also look about sp_tables stored procedure, it can return all the tables or the tables for specific user, look in sql server documentation about sysobjects and sp_tables for more info

Best regards
Mohammed Nasman
0
Stuart_JohnsonAuthor Commented:
Hi Igor,

What you posted is what I don't want to do.  If the table name is FRED.DBF, then it will cut the FRED. off and just leave me with DBF which is wrong.

SQL Server was an example.  The thing can happen with Oracle as well. But this has to work on everything because it's a database management tool I'm writing.  So please, no examples for one type of database.

There must be away to tell the BDE not to return the owner name.  Surely....


Cheers,

Stuart.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

ITugayCommented:
there is an advanced function for get list of tables:

TSession.GetTableNames

it allow you to do not include extensions into table name.

>> There must be away to tell the BDE not to return the owner name.
not sure

0
Mohammed NasmanSoftware DeveloperCommented:
BDE designed specifically for Paradox/DBase, then the SQL links added after that, so not all the BDE Functionality   will work with all types of databases as it working with Paradox, for example if you use BDE to work with Sql server, it can only use the feature in SQL server 6.5 only, for MS access it will working with Access 97 and below, and that's true for most of new databases, and Borland put the BDE in maintenance mode, so it will not be updated anymore

I think if you would design your database management tool to work with the general features maybe BDE will work with you, but if you want it to be more advanced, I think you should consider to change it
0
Stuart_JohnsonAuthor Commented:
Yeah, that's probably right, Mohammed.  Perhaps it's time to stop the development cycle of this version of my app and start working with something else - maybe ADO would be a better approach?

Stu
0
Mohammed NasmanSoftware DeveloperCommented:
Stu, For me I prefer ADO more than BDE, but you should know that Ado Optimized for Microsoft Database(Access & Sql Server), but there's some native drivers for other databases like Oracle, and you can access database that don't have native OLE DB driver using ODBC, I have some applications build using ADO and Oracle, but Microsoft OLE DB driver for Oracle doesn't work with BLOB fields, but if you don't use BLOB it will work fine with other fields, Oracle has it's driver for OLE DB, but I haven't tried it

I'm afraid to tell you, that you will not find any DB framework (BDE,ADO,dbExpress) that will work with all databases as you would, but may I'm wrong about that, the best way to connect to database is using Direct Access Conrols, but the problem that your code will be specific for one database, and will need some modification to work with the others

if you look around about database management tools, you will find they publish specific version for each database, for examples look in www.quest.com, they are using Delphi for developing most of thier applications, but they don't have one application will work with all databases

I think ADO can fit with common databases, but not with all
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Stuart_JohnsonAuthor Commented:
Thanks, Mohammed.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.