none
My Dataset Isn't Returning Double Values from my stored procedure RRS feed

  • Question

  • Hi I am using a MySQL adapter and calling a stored procedure in my c# code, the adapter then fills a DataSet with the results. The problem is that not all the column values are coming through. When I run the procedure on the server it returns all the values for the columns its just the c# portion of it that doesn't. I have noted that the values returned that are not shown are of the double type. How do I fix this?
    Wednesday, January 22, 2020 9:21 AM

All replies

  • It is hard to figure out what is wrong. Please share the relevant portion of your code. Most probably it can be data type mismatch between your DTO and database column.

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


    Blog | LinkedIn | Stack Overflow | Facebook
    profile for Ehsan Sajjad on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, January 22, 2020 10:31 AM
  • ok here's some code

    DataSet ds = new DataSet();
            using (MySqlDataAdapter da1 = new MySqlDataAdapter("CALL myStoredProc(@TSname)", mySQLcon))
            {
                da1.SelectCommand.Parameters.Clear();
                da1.SelectCommand.Parameters.Add("@TSname", MySqlDbType.VarBinary, 100).Value = Path.GetFileNameWithoutExtension(filename);
                da1.SelectCommand.Prepare();
                da1.Fill(ds);            
            }

    But the dataset does not return any values

    Thursday, January 23, 2020 8:00 AM
  • Hello,

    You don't use CALL and don't pass the parameter name in the construction of the adapter. 

    I would suggest asking your question in the MySQL forum

    https://forums.mysql.com/


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, January 28, 2020 10:21 AM
    Moderator
  • Hi ShatterStar2019,

    As Kareninstructor mentioned, just use store procedure name only wihout "call" and related parmaters. here is a sample code for your reference. 

       string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
        using (MySqlConnection con = new MySqlConnection(constr))
        {
            using (MySqlCommand cmd = new MySqlCommand("myStoredProc", con))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@TSname", Path.GetFileNameWithoutExtension(filename));
                using (MySqlDataAdapter sda = new MySqlDataAdapter(cmd))
                {
                    DataTable dt = new DataTable();
                    sda.Fill(dt);             
                }
            }
        }

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 29, 2020 2:26 AM