我在webapi 2中有异常

时间:2018-12-28 07:00:55

标签: mysql asp.net

我正在使用ASP.NET和MySQL开发webapi 2。当我想在列名称为自动增量编译器的本地主机中插入数据时,给我一些错误

Public void RegisterUser (UserRegisterations your)
{

        string Gender = ur.Gender;
        string Password = ur.Password;
        string Email = ur.Email;
        string DOB = ur.DOB;
        string City = ur.City;
        int TelePhone = ur.TelePhone;


        string query = $"INSERT INTO register( Email, TelePhone, Password, Gender, City, DOB)VALUES({Email},'{TelePhone}','{Password}','{Gender}','{City}','{DOB}')";
        //string query = "INSERT INTO register VALUES ('shahzad@gmail.com','a','2','a','a','a')";
        MySqlCommand cmd = new MySqlCommand(query);
        cmd.Connection = Con;
        Con.Open();


        {
            if (Con != null)
            {
                Console.WriteLine("Successed");

            }
            Console.WriteLine("failure");
        }
        cmd.ExecuteNonQuery();
        Con.Close();

    }

0 个答案:

没有答案