简体   繁体   English

ODBC 普遍错误

[英]ODBC Pervasive Error

I am having the hardest time connecting to this pervasive server for this asp.net application I'm working on.对于我正在处理的这个 asp.net 应用程序,我很难连接到这个普遍的服务器。 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.现在,我可以在 Visual Studio 的服务器资源管理器中使用我的连接字符串访问和查看整个数据库,但是当我实际运行它时出现错误。 Here is my code:这是我的代码:

    String myConnectionString = 
        "Driver={Pervasive ODBC Client Interface};servername=192.168.1.2;dbq=@Live;";
    OdbcConnection 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<<???错误 [42000] [普遍][ODBC 客户端接口][LNA][普遍][ODBC 引擎接口]语法错误:驱动程序<<??? >>={Pervasive ODBC Client Interface} >>={普遍的 ODBC 客户端接口}

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:应该有你的 SQL 声明:

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.当您调用 ExecuteReader 行时,SQL 引擎会尝试执行不是有效的 SQL 语句的连接字符串。

I would always use the Pervasive ADO.NET Data Provider.我将始终使用 Pervasive ADO.NET 数据提供程序。 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它应该与数据库引擎一起安装,但如果不是,您可以在这里下载: 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:另外,尝试将连接字符串更改为基本形式并使用 DSN:

ServerDSN=DSNData;UID=username;PWD=password;Server=SERVERNAME

I haven't had any problems with this setup.我对这个设置没有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM