ODBC Pervasive Error
I am having the hardest time connecting to this pervasive server for this asp.net application I'm working on. Right now, I am able to access and view the entire database using my connection string in the server explorer in visual studio however when I actually run it I get an error. Here is my code:
String myConnectionString =
"Driver={Pervasive ODBC Client Interface};servername=192.168.1.2;dbq=@Live;";
Odb开发者_如何学PythoncConnection myConnection = new OdbcConnection(myConnectionString);
OdbcCommand command = new OdbcCommand(myConnectionString, myConnection);
try
{
myConnection.Open();
OdbcDataReader reader = command.ExecuteReader();
reader.Close();
command.Dispose();
myConnection.Close();
}
catch (OdbcException ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message);
}
Here is the error I get when it runs:
ERROR [42000] [Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine Interface]Syntax Error: Driver<< ??? >>={Pervasive ODBC Client Interface}
Any help would be greatly appreciated, even if it is only a wild guess as I'm kind of desperate right now.
Thanks
The line :
OdbcCommand command = new OdbcCommand(myConnectionString, myConnection);
should have your SQL statement in it:
OdbcCommand command = new OdbcCommand("select * from table", myConnection);
rather than the connection string. When you call the ExecuteReader line, the SQL engine tries to execute the connection string which is not a valid SQL statement.
I would always use the Pervasive ADO.NET Data Provider. It should be installed with the database engine, but if it is not you can download it here: http://www.pervasivedb.com/psqlv11/pages/default.aspx
Lots of examples are available as well on their website.
Also, try changing the connection string to be in the basic form and use a DSN:
ServerDSN=DSNData;UID=username;PWD=password;Server=SERVERNAME
I haven't had any problems with this setup.
精彩评论