Data Base Name

I would like to use the data base name in one of my reports, instead of use Company name. How can I do It?

Hi!

There’s a virtual/system table: 2000000048 Database
Just declare a variable, then:

DB.SETRANGE(“My Database”, TRUE);
IF NOT DB.FINDFIRST THEN
DB.INIT;
MyDBName := DB.“Database Name”;

Sorry, but I don’t have that table 2000000048 :frowning:

We have several names since split over multi drives

Database
Database1
Database2
etc.

If your split which one would you want?
2nd - Would getting the server name Suffice?

Perhaps you need to go the CONTEXTURL route. See c/side ref guide.

Since you are on native you would use table 2000000010 Database File instead. The solution suggested by Jorg works only on SQL server.

This would only give you the names of the physical database files, since it is only SQL servers that assign names to the databases, and not native servers.

Using the contexturl, you should be able to retrieve the server ip or hostname. Example:

navision://client/run?servername=192.168.10.11&company=testcompany&servertype=NAVISION

We use Native and what I tested & used is Table 2000000009 - Session

OnInitReport()
mySession.SETRANGE(“My Session”, TRUE);
IF NOT mySession.FIND(’+’) THEN
mySession.INIT;
MyDBName :=SySession.“Database Name”;

Table 2000000010 has these fields - Session is better
1.No.
2.File Name
3.Size (KB)
4.Total Reads
5.Mean Read Time (ms)
6.Reads In Queue
7.Total Writes
8.Mean Write Time (ms)
9.Writes In Queue
10.Disk Load (%)

Hello

I want to get SQL DataBase name.

How should be the CONTEXTURL function?

Hm? Well, if you are running SQL Server there should be this table 2000000048 Database ?!

Have in mind that you cannot see this table in “Object Designer”, but you could use it as variable etc.

HI

You can use session table,Its a virtual table assign this table as a variable.

This table have field called database name.just take a look of below code.session is my variable of session table.

if session.GET() then
begin
session.SETRANGE(session.“User ID”,USERID);
session.SETRANGE(session.“My Session”,true);
message(’%1’,session.“Database Name”);
end;

It ill give the database name with the path as in below message box

5531.DB.bmp (128 KB)

Thanks

Jerome Marshal.J

Hi Jorg?

I declared a C/AL Globals variable DB with Data Type = 2000000048, but i get one error message, that this table does not exist. How can I declare it?

Thanks

Well, I’m afraid one of us is somewhat confused ?! [8-)]
Are you using native or SQL Server database? WIth SQL Server you should have this table, with native not …

Hy Jorg, you are right I forgot that I was doing tests in a DB Native. OK.

AnyWay I am testing your sugget with Table 200000010 - Database fIle, bu something is woron because

DB.SETRANGE(“My Database”, TRUE);
IF NOT DB.FINDFIRST THEN
DB.INIT;
MyDBName := DB.“Database Name”;

I declared DB with DataType = Record 2000000010 (Database fIle)

After compile “My Database” is not a valid variable.???

Now MyDBName contains the name of your database just add it to the souceexp of a textbox