开发者

mysql .net connector not working with a .net 4.0 project and connector 6.4.3 with sprocs

I had to rebuild a machine here and thought I'd just redo my web site in the process. I decided to go with mvc 3 but still use mysql on the back开发者_开发技巧 end.

I essentially copied and pasted all of my old code for the sql connection to return results from a mysql stored procedure and it's not working at all. I then tried creating a simple insert sproc and it doesn't work either. If I use in-line sql on my MySqlCommand, it works fine however (both selecting and inserting). I'm thinking that with .net 4.0 they changed something on the CommandType.StoredProcedure...but I can't say for sure.

When I put a breakpoint on my command call to the actual sproc, it doesn't show anything, nor does it actually do anything. I've called the sprocs from the CLI and they're working just as they should. Back to what I was saying, I'm guessing that with .net 4, it doesn't use the "Call" command any more. Anyone run into this issue? If so, do you have a solution? Is there anyway to import the System.Data 2.0 dll into a .net 4.0 project to verify what I'm thinking?

here's some code on my database layer:

public static BuyCollectionModel GrabBuyData(GridSettings gridSettings)
        {
            int totalRows = 0;
            BuyCollectionModel buys = new BuyCollectionModel();
            using (MySqlConnection myConnection = new MySqlConnection(AppConfig.Connection))            {

                //string sql = "SELECT 100 as totalrows, c.* FROM cBuys as c";
                //MySqlCommand myCommand = new MySqlCommand(sql, myConnection);

                MySqlCommand myCommand = new MySqlCommand("usp_GetBuys", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                myCommand.Parameters.AddWithValue("@startrowvar", gridSettings.PageIndex);
                myCommand.Parameters.AddWithValue("@endrowvar", gridSettings.PageSize);
                myCommand.Parameters.AddWithValue("@sortcolvar", gridSettings.SortColumn);
                myCommand.Parameters.AddWithValue("@sortordervar", gridSettings.SortOrder);
                myConnection.Open();
                using (MySqlDataReader myReader = myCommand.ExecuteReader())
                {
                    while (myReader.Read())
                    {
                        buys.Add(FillBuys(myReader, out totalRows));
                    }
                }
                myConnection.Close();
            }
            buys.TotalCount = totalRows;
            return buys;
        }

as mentioned above, I've also tried creating a simple insert sproc that works fine from the CLI, but when I call it from code using ExecuteNonQuery(), it does nothing...


Try reverting to an older version of the connector. One that works for me is 6.3.4. Also, make sure you are using the exact same version on the server as on your dev workstation.


Is there anyway to import the System.Data 2.0 dll into a .net 4.0 project.....

If you are running visual studio, then click on Project-> Add Reference -> Browse and find there your dlls you want to add to project.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜