开发者

"System.FormatException: Input string was not in a correct format" thrown when filling a dataset through IIS 7 but no error in Cassini?

开发者 https://www.devze.com 2023-03-26 03:16 出处:网络
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 \"Sys

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 开发者_StackOverflowthe 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!


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!


Try in compatibility mode in IE. It solved the problem for us.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号