If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > DBNAMES.cfg Database Names List

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-23-05, 23:57
schwaney schwaney is offline
Registered User
 
Join Date: Jul 2005
Posts: 5
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?
Reply With Quote
  #2 (permalink)  
Old 11-24-05, 09:54
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
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.
Reply With Quote
  #3 (permalink)  
Old 11-24-05, 21:52
schwaney schwaney is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 11-24-05, 22:40
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
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.
Reply With Quote
  #5 (permalink)  
Old 11-24-05, 22:47
schwaney schwaney is offline
Registered User
 
Join Date: Jul 2005
Posts: 5
Nice work. Thanks very much for that.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On