命令执行期间遇到致命错误C#

时间:2018-05-25 06:11:06

标签: c# mysql dapper metro-ui-css

美好的一天!

我遇到问题在命令执行期间遇到致命错误。执行mysql时。

我在这段代码中使用了Dapper。

public void AddNewRecord(string _name, string _num, MetroDateTime _date, string _numPref)
    {
        try
        {
            string _prfnum, _srfnum, _crfnum, _counum;
            using (var conn = GetOpenMySqlConnection())
            {
                switch (_numPref.ToLower())
                {
                    case "prfl - ":
                        _prfnum = _num;
                        string addQry = @"INSERT INTO 
                                            prf ( name, prf_number, date )
                                          VALUES
                                            ( @_name, @_prfnum, @_date );";

                        var getPrf = conn.Execute(addQry);
                        break;
                    case "srfl - ":
                        _srfnum = _num;
                        addQry = @"INSERT INTO 
                                            srf ( name, srf_number, date )
                                          VALUES
                                            ( @_name, @_srfnum, _date );";

                        var getSrf = conn.Execute(addQry);
                        break;
                    case "crfl - ":
                        _crfnum = _num;
                        addQry = @"INSERT INTO 
                                            crf ( name, crf_number, date )
                                          VALUES
                                            ( @_name, @_crfnum, _date );";

                        var getCrf = conn.Execute(addQry);
                        break;
                    case "sofl - ":
                        _counum = _num;
                        addQry = @"INSERT INTO 
                                            cou ( name, cou_number, date )
                                          VALUES
                                            ( @_name, @_counum, _date );";

                        var getCou = conn.Execute(addQry);
                        break;
                }

            }
        }
        catch (MySqlException ex)
        {
            throw ex;
        }
    }

我觉得错误发生在日期。 我在Mysql上使用MetroDateTime _date和DateTime日期。

这真的是问题吗?

我是Mysql的初学者,我非常感谢你的回复。

谢谢你和Godbless!

0 个答案:

没有答案