| Bug #40751 | Connector/NET 5.2.4 ExecuteScalar broken | ||
|---|---|---|---|
| Submitted: | 14 Nov 2008 18:15 | Modified: | 14 Nov 2008 21:27 |
| Reporter: | Chris Oosthuizen | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / NET | Severity: | S2 (Serious) |
| Version: | 5.2.4 | OS: | Windows (XP SP2) |
| Assigned to: | CPU Architecture: | Any | |
[14 Nov 2008 18:33]
Reggie Burnett
Chris
I can't reproduce this. Here is the code I am using against a 5.0 server
using (MySqlConnection c = new MySqlConnection("server=localhost;database=test;uid=root"))
{
c.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = "spTest";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = c;
cmd.Parameters.Add("@id", MySqlDbType.Int32).Value = 1;
object o = cmd.ExecuteScalar();
}
[14 Nov 2008 18:42]
Chris Oosthuizen
Reggie, I am running MySql 5.1.29 After having this problem, I simply uninstalled Connector/Net 5.2.4, installed Connector/NET 5.2.2 and the code works. Just to make sure I did nothing crazy, I uninstalled 5.2.2, reinstalled 5.2.4 and reproduced the problem. Right now I am back to 5.2.2 and experiencing no problem. Cheers, Chris
[14 Nov 2008 18:47]
Reggie Burnett
Are you using mysql on linux or some other system that might have case issues?
[14 Nov 2008 19:06]
Chris Oosthuizen
Reggie, Nope - as stated in this bug, I use it on Windows XP SP 2 Chris
[14 Nov 2008 19:16]
Reggie Burnett
Chris I'm trying to figure out what is going on here because it is simply not true that this flatly doesn't work. I have a test suite and example projects that prove it does work. do you have a proc and function of the same name in the same database?
[14 Nov 2008 21:27]
Chris Oosthuizen
Reggie, Your question regarding case sensitivity lead me to check. In my connectionstring I was refering to my database in uppercase. When I change the connectionstring to all lowercase, the cmd.ExecueScalar functioned properly. Thanks,for helping me figure this out. Chris

Description: ExecuteScalar Method fails with exception "Procedure or Function xxxx not found in database yyyy". How to repeat: Create a database with one table and one stored procedure In C#, create function that 1. Creates a connection 2. Creates a Command with syntax "MySqlCommand cmd = conn.CreateCommand();" 3. Populate cmd with cmd.CommandText = "<the stored procedure name>"; cmd.CommandType = System.Data.CommandType.StoredProcedure; 4. Execute the command try { cmd.ExecuteScalar(); } catch (MySqlException e) { <process exception> } Suggested fix: None