addnew 之后记录集更新时出错,表示即使默认设置为空字符串,列也不能为空
我有一个我一直支持的程序,最近安装在 Windows 7 计算机上。一切都正常,但是最近这台机器开始收到以下错误,在修改字段后使用 recordset.update 方法时,我收到了以下错误。
-2147467259([MySQL][ODBC 3.51 驱动程序][mysqld-4.0.18-nt]列“fd_number”不能为空)
表 'fd_number' 看起来像这样:
CREATE TABLE `bookguide` (
`author` varchar(100) NOT NULL default '',
`title` varchar(100) NOT NULL default '',
`isbn` varchar(13) NOT NULL default '',
`whls` decimal(10,2) NOT NULL default '0.0000',
`oldwhls` decimal(10,2) NOT NULL default '0.0000',
`fd_number` varchar(100) NOT NULL default '',
KEY `isbn` (`isbn`)
) TYPE=MyISAM;
修改这个表的代码看起来像这样
780 Do While Not txtstream.AtEndOfStream
790 Line = txtstream.ReadLine
800 rs.addNew
'tempwhole = Mid$(line, 2, 9) + Mid$(line, 119, 1)
810 author = Mid$(Line, 10, 15)
820 author = Replace(author, "'", "")
830 author = Replace(author, ",", "")
840 title = Mid$(Line, 25, 70)
850 title = Replace(title, "'", "")
860 title = Replace(title, ",", "")
'tempisbn = Mid$(tempwhole, 2, 8)
870 rs.fields("isbn").Value = Replace(Trim$(Mid$(Line, 95, 13)), "-", "")
880 rs.fields("author").Value = author
890 rs.fields("title").Value = title
900 rs.fields("whls").Value = Val(Mid$(Line, 139, 5))
910 rs.Update
920 Loop
:这只是失败的一个例子,整个程序中很可能有数千次更新/插入都是通过这种方式完成的。
我曾多次尝试重新安装 MySQL ODBC 3.51 驱动程序 (3.51.27),包括使用旧版本 (3.51.06),这消除了 ADO 问题,但引入了一个错误,显示了 的效果在上述循环之后,ODBC 驱动程序不支持此代码段所请求的属性。
940 rs.Open "UPDATE bookguide SET oldwhls = whls, whls = 0",conn
I've got a program that i've been supporting that recently was installed on a windows 7 machine. Everything has been working however recently this machine has started Receiving the following error when using the recordset.update method after modifying fields i've received the following error.
-2147467259 ([MySQL][ODBC 3.51 Driver][mysqld-4.0.18-nt]Column 'fd_number' cannot be null)
The table 'fd_number' is in looks like this:
CREATE TABLE `bookguide` (
`author` varchar(100) NOT NULL default '',
`title` varchar(100) NOT NULL default '',
`isbn` varchar(13) NOT NULL default '',
`whls` decimal(10,2) NOT NULL default '0.0000',
`oldwhls` decimal(10,2) NOT NULL default '0.0000',
`fd_number` varchar(100) NOT NULL default '',
KEY `isbn` (`isbn`)
) TYPE=MyISAM;
The code that modifies this table looks like this:
780 Do While Not txtstream.AtEndOfStream
790 Line = txtstream.ReadLine
800 rs.addNew
'tempwhole = Mid$(line, 2, 9) + Mid$(line, 119, 1)
810 author = Mid$(Line, 10, 15)
820 author = Replace(author, "'", "")
830 author = Replace(author, ",", "")
840 title = Mid$(Line, 25, 70)
850 title = Replace(title, "'", "")
860 title = Replace(title, ",", "")
'tempisbn = Mid$(tempwhole, 2, 8)
870 rs.fields("isbn").Value = Replace(Trim$(Mid$(Line, 95, 13)), "-", "")
880 rs.fields("author").Value = author
890 rs.fields("title").Value = title
900 rs.fields("whls").Value = Val(Mid$(Line, 139, 5))
910 rs.Update
920 Loop
This is just one example of where this is failing, There are most likely thousands of updates/inserts done this way through out the entire program.
I've attempted to reinstall of MySQL ODBC 3.51 Driver (3.51.27) several times, including using an older version (3.51.06), which takes away the ADO problem but introduces an error that says something to the effect of ODBC Driver does not support the requested Properties on this section of code right after the above loop.
940 rs.Open "UPDATE bookguide SET oldwhls = whls, whls = 0",conn
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题似乎是 ODBC 驱动程序的多个版本,新版本/旧版本的卸载似乎仍然将 dll 和 lib 文件留在 sysWOW64 中,一旦我卸载了两个版本的 myODBC 并从中删除了文件sysWOW64 目录并重新安装 3.51.27 驱动程序错误已消失。
The issue it seems to be was that the multiple versions of the ODBC driver, the uninstalls for the the newer one/old one still seemed to leave the dlls and lib files in sysWOW64, Once I uninstalled both version of myODBC and removed the files from the sysWOW64 directory and reinstalled the 3.51.27 driver the error has disappeared.
您的默认值
''
似乎未应用于该字段。您是否尝试过 MySQL ODBC 驱动程序 5.1.7 ?It looks like your default value of
''
is not being applied on that field. Have you tried the MySQL ODBC driver 5.1.7 ?