“System.FormatException:输入字符串的格式不正确”通过 IIS 7 填充数据集时抛出错误,但 Cassini 中没有错误?
Visual Studio 2010 Express、ASP.NET MVC3、C#,在 Windows Server 2008 R2 上具有 ODBC 数据连接。
当使用 Visual Studio 的内置 Web 服务器时,此代码按预期运行,但在通过 IIS7 运行时失败,并出现“System.FormatException”。
OdbcConnection conn = new OdbcConnection("Dsn=MyDSN");
OdbcDataReader reader = null;
string result = "";
try
{
conn.Open();
OdbcCommand cmd = new OdbcCommand("select * from my_table limit 3 offset 10", conn);
cmd.CommandType = CommandType.Text;
DataSet ds = new DataSet();
OdbcDataAdapter da = new OdbcDataAdapter(cmd);
da.Fill(ds); // Fails right here when viewed through IIS7 with a FormatException
.
.
.
……我完全不知所措。我可以接受返回数据中存在导致此异常的可能性,但我希望它也能在卡西尼号中体现出来!
有谁对如何解决此问题有任何建议,或者为什么 IIS7 和 Visual Studio 的内置 Web 服务器之间存在如此大的行为差异?
谢谢!
Visual Studio 2010 Express, ASP.NET MVC3, C# with an ODBC data connection on Windows Server 2008 R2.
This code runs as expected when using Visual Studio's built-in web server, but fails with a "System.FormatException" when run through IIS7.
OdbcConnection conn = new OdbcConnection("Dsn=MyDSN");
OdbcDataReader reader = null;
string result = "";
try
{
conn.Open();
OdbcCommand cmd = new OdbcCommand("select * from my_table limit 3 offset 10", conn);
cmd.CommandType = CommandType.Text;
DataSet ds = new DataSet();
OdbcDataAdapter da = new OdbcDataAdapter(cmd);
da.Fill(ds); // Fails right here when viewed through IIS7 with a FormatException
.
.
.
... I'm at a total loss. I can accept the possibility of there being something in the returned data that causes this exception, but I'd hope it'd manifest itself in Cassini as well!
Does anyone have any suggestions in how to fix this problem or why there's such a difference of behavior between IIS7 and Visual Studio's built-in webserver?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决了。这是 32 位与 64 位的问题。将网站的应用程序池设置为 32 位运行解决了这个问题!
Solved. This was a 32-bit vs. 64-bit issue. Setting the application pool for the site to run as 32-bit fixed the problem!
IE 兼容模式下试试。它为我们解决了问题。
Try in compatibility mode in IE. It solved the problem for us.