简体   繁体   English

Pervasive SQL 中没有详细信息的语法错误

[英]Syntax Error without details in Pervasive SQL

I am getting an error talking to a Pervasive SQL database, but without much details about what could be wrong.我在与 Pervasive SQL 数据库交谈时遇到错误,但没有太多关于可能出错的细节。 Do you have any advice about how I could debug where the problem is您对我如何调试问题所在有什么建议吗

Pervasive.Data.SqlClient.Lna.k: [LNA][PSQL][SQL Engine]Syntax Error.
   at Pervasive.Data.SqlClient.Lna.w.a(String , ad , l )
   at Pervasive.Data.SqlClient.PsqlCommand.a(Boolean , CommandBehavior , Boolean )
   at Pervasive.Data.SqlClient.PsqlCommand.ExecuteNonQuery()

Here is the code这是代码

using (PsqlCommand command = new PsqlCommand(sql, psqlConnection))
{
  command.Parameters.Clear();
  command.CommandText = sql;
  command.Parameters.AddWithValue("@KidDate", companyKIDDate);
  command.Parameters.AddWithValue("@KidTime", companyKIDTime);
  command.Parameters.AddWithValue("@KidMult", companyKIDMult);
  command.Parameters.AddWithValue("@KidComm", companyKIDComm);
  command.Parameters.AddWithValue("@DateGmt", companyKIDDate);
  command.Parameters.AddWithValue("@TimeGmt", companyKIDTime);
  command.Parameters.AddWithValue("@Seconds", companyKIDTime);  
  result = command.ExecuteNonQuery();
}

The query sql in the code is (keeping the weird formatting for exactitude).代码中的查询sql是(保持奇怪的精确格式)。

INSERT INTO "FMUPDATE"
                        ("KID - date", "KID - time", "KID - user", "KID - mult", "KID - comm",
                        "Date GMT", "Time GMT",
                        "Flag",
                        "Pax Update",
                        "User ID",
                        "Count",
                        "Seconds",
                        "RockstarFlag")
                        VALUES(?, ?, 'RF01', ?, ?,
                        ?, ?,
                        1, 
                        1,
                        'RF01',
                        1,
                        ?,
                        1);

And here is the PsqlTrace of the error这是错误的PsqlTrace

00000001 09:21:53.704 T1 I43089283 Command::ExecuteNonQuery ENTER

    CommandText:      INSERT INTO "FMUPDATE"
                        ("KID - date", "KID - time", "KID - user", "KID - mult", "KID - comm",
                        "Date GMT", "Time GMT",
                        "Flag",
                        "Pax Update",
                        "User ID",
                        "Count",
                        "Seconds",
                        "RockstarFlag")
                        VALUES(?, ?, 'RF01', ?, ?,
                        ?, ?,
                        1, 
                        1,
                        'RF01',
                        1,
                        ?,
                        1);
    CommandType:      Text
    CommandTimeout:   30
    UpdatedRowSource: Both
    Par #1: @KidDate, Input, String, 0, System.Int32, 44755
    Par #2: @KidTime, Input, String, 0, System.Int32, 982
    Par #3: @KidMult, Input, String, 0, System.Int32, 128
    Par #4: @KidComm, Input, String, 0, System.Int32, 1
    Par #5: @DateGmt, Input, String, 0, System.Int32, 44755
    Par #6: @TimeGmt, Input, String, 0, System.Int32, 982
    Par #7: @Seconds, Input, String, 0, System.Int32, 982

    Error or Warning Received from Pervasive Server
    Number    = 0
    Message   = Pervasive.Data.SqlClient.Lna.k: [LNA][PSQL][SQL Engine]Syntax Error.
    Error Position = 37000

00000001 09:21:53.751 T1 I43089283 Command::ExecuteNonQuery EXIT
    Return: 0

The MKDE.TRA file is a Btrieve / Transactional engine level trace. MKDE.TRA 文件是 Btrieve / Transactional 引擎级别的跟踪。 The error you are seeing is a Relational engine error.您看到的错误是关系引擎错误。 Some Relational engine errors are the same as Transactional / Btrieve errors but most are not.一些关系引擎错误与事务/Btrieve 错误相同,但大多数不是。 You can turn on tracing within the Pervasive.Data.SqlClient interface using code like below:您可以使用以下代码在 Pervasive.Data.SqlClient 接口中打开跟踪:

PsqlTrace.TraceFile = "C:\\source\\debug\\MyTrace.txt";
PsqlTrace.RecreateTrace = 1;
PsqlTrace.EnableTrace = 1;

This will generate a file that has a format like:这将生成一个格式如下的文件:

Assembly Name:         Pervasive.Data.SqlClient, Version=4.1.0.0, Culture=neutral, PublicKeyToken=c84cd5c63851e072
Assembly File Version: 4.1.0.005024

00000001 19:48:31.703 T1 I30015890 Command::ExecuteNonQuery ENTER

    CommandText:      INSERT INTO Table1 ("KID -NAME", name, number) VALUES (?, ?, ?)
    CommandType:      Text
    CommandTimeout:   30
    UpdatedRowSource: Both
    Par #1: @KIDname, Input, String, 0, System.String, "name"
    Par #2: name, Input, String, 0, System.String, "name"
    Par #3: number, Input, String, 0, System.Int32, 88

    Error or Warning Received from Pervasive Server
    Number    = 0
    Message   = Pervasive.Data.SqlClient.Lna.w: [LNA][Pervasive][ODBC Engine Interface]Invalid column name: 'KID -NAME'.
    Error Position = 0

00000001 19:48:31.759 T1 I30015890 Command::ExecuteNonQuery EXIT
    Return: 0

Since this doesn't always happen, I would enable / disable the trace only around the calls that fail.由于这并不总是发生,我将仅在失败的调用周围启用/禁用跟踪。 Once you get the error, take a look at the trace and see if there's any more information.一旦你得到错误,看看跟踪,看看是否有更多信息。 Posting here might get more eyes on it.在这里发帖可能会引起更多关注。 If I had to guess, I would say that some value you are passing is invalid (00-00-0000 for a date, string for an integer, etc.).如果我不得不猜测,我会说您传递的某些值是无效的(日期为 00-00-0000,整数为字符串等)。

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

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