Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create database in DBNames

Status
Not open for further replies.

suntanme

Programmer
Jul 20, 2002
16
US
As a beginner, I am using IS 7.0 to install a Pervasive database and application. Every thing works great except I can not figure out how to define a new named database in the Windows dbnames.cgf file so that Pervasive knows where the dictionary and data file are located. Does anyone have a suggestion or a another way for Pervasive to find the locations? Thank you Ed
 
You have several options for creating Database Names. One, you can have the user create it after the app and Pervasive is installed (not very user friendly). Two, you can create it using DTO/DTI from your application on start up if it doesn't find the one it needs. Three, you can create the Database Name with DTI or DTO using InstallShield. What version of InstallShield are you using? There's some samples on Pervasive's Dev Center.
info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
Thank you!

I'm using Install Shield Developer 7.0 and would like to setup the DBName during installation. The setup for a server is very clear, however I will be setting up the database for a workstation. How would I connect to a local machine?

Again THANK YOU!,
Ed
 
Here's some DTO code:
Code:
function DTOTest()
	
	string szCompName,szUser,szPassword, svString; 
	object objDTO;                          
	number result,nResult;                   
	string Desc;
	object m_DtoDatabase;	 
	object m_DtoDSN;  
	
begin                       
	nResult = AskText ("Local Computer Name", "", szCompName); 
	if (nResult = NEXT) then 
		nResult = AskText ("Admin User", "", szUser); 
	endif;
	if (nResult = NEXT) then 	
		nResult = AskText ("Password", "", szPassword); 
	endif;
	
	//nResult = SdShowAnyDialog("DTO INformation","",12033,0); 
	
	if (nResult = NEXT) then
		set objDTO = CreateObject("DTO.DtoSession.1");
		result = objDTO.Connect(szCompName,szUser,szPassword);
    	if (result != 0) then
    		MessageBox("Error Connecting", INFORMATION);
    	else                                               
	   			// now that we're connected, let's create a DBN and DSN
	   			set m_DtoDatabase = CreateObject("DTO.DtoDatabase.1"); 
	   			
	   			m_DtoDatabase.DataPath = INSTALLDIR;
	   			m_DtoDatabase.DdfPath = INSTALLDIR;
	   			m_DtoDatabase.Name = "DTO Test from IS";
	   			m_DtoDatabase.Flags = 0;     
	   			try
	   			nResult = objDTO.Databases.Add(m_DtoDatabase);   
   			if (nResult = 0) then
   				//DBN Created, now let's create the DSN 
   				set m_DtoDSN = CreateObject("DTO.DtoDSN.1"); 
   				MessageBox ("Added DBN.",INFORMATION);
   				m_DtoDSN.DBName = m_DtoDatabase.Name;
   				m_DtoDSN.Description = "DTO DSN Created through IS7";
   				m_DtoDSN.OpenMode =  0; //sets normal open mode
   				m_DtoDSN.Name = "IS7 DTO DSN";
   				nResult = objDTO.DSNs.Add(m_DtoDSN);
   				MessageBox ("DSN Add completed.",INFORMATION);
   				if (nResult = 0) then
   					//DSN Created.
   				else   
   					result = NumToStr (svString, nResult);
   					MessageBox("Error Creating DSN. " ^ svString,SEVERE);
   				endif;
   			else
   				//DBN not Created.       
   				nResult = NumToStr (svString, result);
                SetDialogTitle ( DLG_MSG_INFORMATION, "Error Creating DBN" );   	                          
   				MessageBox("Error creating DBN: " ^ svString ,SEVERE);
   		    endif;                                          
   		    catch           
   		    	        
   		    	Desc = "In Catch. " + Err.Description;
 				
 				SetDialogTitle ( DLG_MSG_INFORMATION, "Error Description" );   	                          
   		    	MessageBox(Desc, SEVERE);
   		    endcatch;
   			
    	endif;
    	result = objDTO.Disconnect;
    //set objDTO = nothing;
    endif;
end;
info@mirtheil.com
Custom VB and Btrieve development.
Certified Pervasive Developer
Certified Pervasive Technician
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top