Server Name

SteveSteve Member Posts: 81
Looking for a way in code to determine what the SQL server name and database name. Any ideas?
Steve

Comments

  • SavatageSavatage Member Posts: 7,142
    http://www.mibuso.com/howtoinfo.asp?FileID=2

    We also Use the code below to get:
    1. Today's Date
    2. User's Name
    3. Company's Name
    4. Computer's Name
    5. IP Address
    6. Database name
    7. Server Info
    TotalDate := FORMAT(WORKDATE,0,'<Weekday Text>, <Month Text> <Day>, <year4>');
    User.GET(USERID);
    CompanyInfo.GET;
    
    IF ISCLEAR(WSHShell) THEN 
      CREATE(WSHShell); 
    
    WSHExec := WSHShell.Exec('nslookup ' + ENVIRON('computername'));
    WSHTxt := WSHExec.StdOut;
    WSHTxt.SkipLine;
    WSHTxt.SkipLine;
    WSHTxt.SkipLine;
    ComputerName := COPYSTR(WSHTxt.ReadLine,1,80);
    ComputerIP := COPYSTR(WSHTxt.ReadLine,10,80);
    CLEAR(WSHShell); 
    ComputerName:= (ENVIRON('computername'));
    
    MyContext := CONTEXTURL;
    MyDatabase := COPYSTR(MyContext,1,44);
    MyServer := COPYSTR(MyContext,73,50);
    
  • kinekine Member Posts: 12,562
    Or you can read it from the Context URL...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.