我们用的.NET 2.0 + OpendLink ODBC Driver (5.2 版本) 读写Informix 库某一个表,同样的SQL 语句总是随机性地出现错,大约十次有一次出错,已经排除SQL语法和数据库约束这类错误,目前我们把错误定位在OpendLink ODBC Driver 本身的Bug或配置不当上.
主要代码如下:
System.Data.Odbc.OdbcConnection _connection
......
......
_connection = new System.Data.Odbc.OdbcConnection( "FILEDSN=myDSN;Uid=root;Pwd=; ");
_connection.Open();
......
......
System.Data.Odbc.OdbcCommand command = new System.Data.Odbc.OdbcCommand( "DELETE FROM cmstbls WHERE tabname = 'AAA ' AND colname = 'BBB '; ");
command.Connection = _connection ;
command.CommandType = CommandType.Text;
command.UpdatedRowSource = UpdateRowSource.None;
command.ExecuteNonQuery();
DSN配置如下:
[ODBC]
DRIVER=OpenLink Generic ODBC Driver
UID=root
SqlDbmsName=
FetchBufferSize=60
UseSSL=No
NoLoginBox=No
DeferLongFetch=No
ReadOnly=No
Options=192.168.10.18
Database=CMS
ServerType=Informix 2000
Host=192.168.10.18:5000
Server=OpenLink
随机出的错误有两种,看着都很不合理:
1. System.Data.Odbc.OdbcException: ERROR [42000] [OpenLink][ODBC][Informix Server]A syntax error has occurred. (-201)
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteNonQuery()
at TestOpenLinkDirver.Form1.btnRunCommand_Click(Object sender, EventArgs e) in C:\Working\Interaction Data Service\TestOpenLinkDirver\Form1.cs:line 69
2. System.Data.Odbc.OdbcException: ERROR [HY000] [OpenLink][ODBC][Informix Server]An illegal character has been found in the statement. (-202)
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteNonQuery()
at TestOpenLinkDirver.Form1.btnRunCommand_Click(Object sender, EventArgs e) in C:\Working\Interaction Data Service\TestOpenLinkDirver\Form1.cs:line 69
我的问题:
1. 有没有朋友也出现过类似的错误?是不是这个OpendLink ODBC Driver 本身的Bug?
2. 如果不用OpendLink ODBC Driver ,有哪些其它的Driver 对Informix 的操作比较可靠,建议一下.