Solved

Error on connection string to Btrieve "database"

Posted on 2006-11-14
17
1,550 Views
Last Modified: 2013-12-25
I am trying to connect to a Btrieve "database" on a server from my Visual Studio .NET C# code on my machine, but I am getting the Error "Data source name not found and no default driver specified".
Here is the connection string that I have:

Driver={Pervasive ODBC-32};DDFPATH=\\<server>\WinMPM22\<folder1>\<folderWithBtrieveFiles>;DATAPATH=\\pbydata1\WinMPM22\<folder1>\<folderWithBtrieveFiles>

I have tried using a connection string specifying the Server and the Database, but it gives the error as well, but I don't understand how it could find the database that way anyways since you have to navigate through several folders to get to it.

The path that I have specified has .DDF files as well as the data files. I am really getting frustrated with this and need a solution fast. Can someone please help?
Thanks,
Jen
0
Comment
Question by:jenndo
  • 7
  • 5
  • 5
17 Comments
 
LVL 1

Expert Comment

by:wayne_freeman
ID: 17940433
Hi Jen, it looks like a DSN doesn't exist for that database, which would make it easier.

If OLEDB is available, which it probably is if you're using .NET, you could use a connect string similar to this:

Provider=PervasiveOLEDB;Server=<server>;Data Source=<PathToDDFs> | <DSN Name>;User ID=<userid>;Password=<password>

If you want to use a DSN-less connection, just put the PathToDDFs in the Data Source parameter, or you can create a DSN through the Data Source Manager or ODBC Administrator and insert that DSN Name in the Data Source parameter.

Wayne Freeman
Analytica Business Systems
www.analyticabiz.com
0
 
LVL 18

Expert Comment

by:mirtheil
ID: 17940604
A couple of quesitons:
- What version of PSQL/Btrieve are you using?  
- Are you using the OdbcConnection, OleDbConnection, or PsqlConnection object?  

Once you give the version of PSQL you're using, we can help with the Connection string.

The following C# code works for me with PSQL v8 and v9 (using the DSN DEMODATA).
using System;
using System.Data;
using System.IO;

namespace SimpleAdoNetConsole
{
      class Class1
      {
            [STAThread]
            static void Main(string[] args)
            {
                  try
                  {
                        OdbcConnection conn=new OdbcConnection("Driver={Pervasive ODBC Engine Interface};DBQ=DEMODATA;");
                        conn.Open();
                        // Create a SQL command
                        string SQLstr = "";
                        SQLstr = "SELECT * FROM CLASS";

                        OdbcCommand DBCmd = new OdbcCommand(SQLstr, conn);
                        OdbcDataReader myDataReader;
                        myDataReader = DBCmd.ExecuteReader();
                        Console.WriteLine("FieldCount: " + myDataReader.FieldCount.ToString());
                        \while (myDataReader.Read())
                        {
                              for (int i=0;i<myDataReader.FieldCount;i++)
                              {
                                    Console.WriteLine("Field " + i.ToString() + ": " + myDataReader[i].ToString());
                              }
                        }
                        myDataReader.Close();
                        conn.Close();
                        Console.WriteLine("Press Enter to continue");
                        Console.ReadLine();
                  }
                  catch (Exception ex)
                  {
                        Console.WriteLine(ex.Message);
                        Console.ReadLine();
                  }
                  
            }
      }
}
0
 

Author Comment

by:jenndo
ID: 17940636
I am using version 8 and I am using OdbcConnection.
I am trying to use a DSN-less connection string because I do not have access to the server the database files are on, not to mention I don't want to create a DSN for every database I want to access because there are a lot of them.

Thanks~
0
 

Author Comment

by:jenndo
ID: 17940735
Could it possibly have to do with security issues? If so, how would I figure out where the security issue lies?
0
 
LVL 18

Expert Comment

by:mirtheil
ID: 17940763
Okay, with PSQL 8, you can't use the "Pervasive ODBC-32" driver because it doesn't exist.  You need to use the "Pervasive ODBC Client Interface" or the "Pervasive ODBC ENgine Interface".  

PSQL v8 doesn't really support using paths. You'd need to create at least a Pervasive Engine DSN on the server. Once you do that, you can use:
"Driver={Pervsive ODBC CLient Interface};ServerName=<servername>;ServerDSN=<serverDSN>"
0
 

Author Comment

by:jenndo
ID: 17940787
So I would have to create a DSN for every database I want to access?
0
 
LVL 18

Expert Comment

by:mirtheil
ID: 17940808
One the server, yes.  How many databases are you trying to access?
0
 
LVL 1

Expert Comment

by:wayne_freeman
ID: 17940820
Yes, you would.  There are ways to automate that, though.

This will give you some hints about that:

http://www.analyticabiz.com/Updatearticlesview.php?ID1=51

Wayne
www.analyticabiz.com
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:jenndo
ID: 17940821
Well, I'm not exactly sure yet. It could be anywhere between 10 and much more than that. :-/
0
 
LVL 1

Expert Comment

by:wayne_freeman
ID: 17940830
If the DSN exists on each server, all you would need is the name of each one.  Are they the same name on every server?

Wayne
0
 

Author Comment

by:jenndo
ID: 17940856
I'm not sure I understand what you're asking Wayne. The database files exist on one server. I'm understanding that I have to create a DSN for each database on that server.
0
 
LVL 1

Expert Comment

by:wayne_freeman
ID: 17940905
Oh, okay, I thought you were accessing a number of servers.  I understand now.

Yes, you have to create a DSN for every database.  My suggestion on ways to automate that still stands, but you would have to weigh the effort of each method of automation against the probably less effort of just doing it through the wizard.

My experience has been that creating one DSN through the wizard and then exporting, modifying, and re-importing the registry entries is fairly easy.

Wayne
0
 
LVL 18

Expert Comment

by:mirtheil
ID: 17941047
THere are other ways to automate creating the DSN/DBNs as well using DTO/DTI functions from the Pervasive SDK.  

Are you saying you've got 10+ sets of DDFs and data files and need to access each one?  
0
 

Author Comment

by:jenndo
ID: 17941082
That is correct.
There is a way I just found out to be able to dynamically create DSN's, but I haven't started messing with it yet to find out if it will work or not. What do the DTO/DTI functions from the Pervasive SDK do?
0
 
LVL 18

Accepted Solution

by:
mirtheil earned 300 total points
ID: 17941145
The DTI/DTO functions allow you to create DSNs/DBN on the server from within an application.  With .NET, I would suggest DTO because it's COM based.  DTI would be "unsafe" functions.  
0
 
LVL 1

Assisted Solution

by:wayne_freeman
wayne_freeman earned 200 total points
ID: 17941147
The DTI is a set of APIs, with which you can do a lot of the database maintenance and configuration from within an application, using embedded DTI/DTO calls to perform administrative functions that would typically require the use of external utilities like the Pervasive Control Center and the ODBC Administrator.

The DTI lets you do things inside an app like create databases, adjust parameters, obtain file handle usage, etc.

The DTO is a set of objects that abstract the DTI functions.

Wayne
www.analyticabiz.com
0
 

Author Comment

by:jenndo
ID: 17941217
Thanks for the info and help guys!
~Jen
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now