Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2005
    Posts
    5

    Unanswered: DBNAMES.cfg Database Names List

    I am looking for a way to construct a list of DataBase Names so that users can select the DSN they want to connect to. I can see that all the information that I require is in the DBNAMES.cfg file, but I can not find a layout for deciphering it programmatically. Is anyone aware of a layout guide or whether the names can be extracted via the SDK?

  2. #2
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    What version of Pervasive are you using? Also, which language are you using?
    If you are using PSQL 2000 or later (V8 or V9), you can use DTI or DTO. You're not going to want to try to read DBNAMES.CFG directly as it might change sturcture between versions.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  3. #3
    Join Date
    Jul 2005
    Posts
    5
    Thanks for coming back. I am using Pervasive 9 and the language is VB.NET. Sorry for my ignornace, but I am not sure what DTI or DTO is.

  4. #4
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    DTI is the Distributed Tuning Interface and DTO is the Distributed Tuning Object. They are interfaces to access the PSQL management functions (like Monitor, DBNames, Settings, etc). I don't have any VB.NET code but here's a small C# sample that I got:
    Code:
    using System;
    using DTOLib;
    
    namespace dtoTest
    {
    	/// <summary>
    	/// Summary description for Class1.
    	/// </summary>
    	class Class1
    	{
    		/// <summary>
    		/// The main entry point for the application.
    		/// </summary>
    		[STAThread]
    		static void Main(string[] args)
    		{
    			string compName = null;
    			string userName = null;
    			string password = null;
    			DTOLib.dtoResult result ;
    			if (args.LongLength < 1)
    			{
    				Console.WriteLine("Invalid options.\n");
    				return;
    			}
    			if (args.LongLength == 3)
    			{
    				compName = args[0].ToString();
    				userName = args[1].ToString();
    				password = args[2].ToString();
    			}
    			Console.WriteLine("Pervasive Sample using DTO and C#");
    			Console.WriteLine("Lists defined Pervasive Database Names and associated information.");
    			Console.WriteLine("Copyright 2003 Pervasive Software");
    			DtoSession mDtoSession = new DTOLib.DtoSession();
    			try
    			{
    				result = mDtoSession.Connect (compName, userName, password);
    				if (result != 0)
    				{
    					Console.WriteLine("Error connecting to server.  Error code:");
    				}
    				else
    				{
    					Console.WriteLine("Connected to " + mDtoSession.ServerName );
    					DtoDatabase mDtoDatabase = new DTOLib.DtoDatabaseClass();
    					int dbnCount =  mDtoSession.DSNs.Count;
    					Console.WriteLine("Found " + dbnCount.ToString() + " DBNs");
    					for (int iCount = 1; iCount <= dbnCount; iCount++)
    					{
    						Console.WriteLine("DBN " + iCount.ToString() + ": ");
    						mDtoDatabase = mDtoSession.Databases[iCount];
    						Console.WriteLine("Name: " + mDtoDatabase.Name);
    						Console.WriteLine("DDF Path: " + mDtoDatabase.DdfPath.ToString());
    						Console.WriteLine("Data Path: " + mDtoDatabase.DataPath.ToString());
    						Console.WriteLine("Flags: " + mDtoDatabase.Flags.ToString());
    						Console.WriteLine("");
    					}
    
    					result = mDtoSession.Disconnect();
    					Console.ReadLine();
    				}
    			}
    			catch (Exception e1)
    			{
    				Console.WriteLine(e1.Message.ToString());
    			}
    		}
    	}
    	}
    You'll need to add the DTO library (COM interface) as a reference.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  5. #5
    Join Date
    Jul 2005
    Posts
    5
    Nice work. Thanks very much for that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •