我的代码
string query = @"INSERT INTO representative_dev.representative_users
(Username, Password, FullName,
HomePhone, PhoneToCall,
CompanyEmail, PersonalEmail,
IsManager)
VALUES (@Username, @Password, @FullName,
@HomePhone, @PhoneToCall,
@CompanyEmail, @PersonalEmail,
@IsManager);";
mycon.Open();
int cnt = mycon.Execute(query,
new
{
txtUsername,
txtPassword,
txtFullName,
txtHomePhone,
txtPhoneToCall,
txtCompanyEmail,
txtPersonalEmail,
cbxIsManager
});
mycon.Close();
它给了我“命令执行期间遇到的致命错误”。
当我在另一种情况下执行另一个插入查询时效果很好,不同的是这里我有 cbxIsManager 作为布尔值,而在数据库中是 tinyint(1) 而在另一种情况下都是字符串
如果我添加“允许用户变量=true;” 然后我没有得到异常,但在数据库中所有值都是空的(检查他是否得到值)
在这个项目中使用 ASP.NET,在另一个控制台,FW4,mysql 是 6.somthing(想想 3)其他代码
string query = @"INSERT INTO representative_dev.potencial_contact
(Name, Company_ID, Phone, Email, Department, Notes, SuperFriend, UpdateDate)
VALUES (@Name, @Company_ID, @Phone, @Email, @Department, @Notes, @SuperFriend, @UpdateDate);";
mycon.Open();
int cnt = mycon.Execute(query,
new
{
con.Name,
con.Company_ID,
con.Phone,
con.Email,
con.Department,
con.Notes,
con.SuperFriend,
con.UpdateDate
});
mycon.Close();
任何帮助,将不胜感激
谢谢,爱丽儿
编辑:这是什么时候起作用的
string query = @"INSERT INTO representative_dev.representative_users
(Username, Password, FullName,
HomePhone, PhoneToCall,
CompanyEmail, PersonalEmail,
IsManager)
VALUES ('" + txtUsername + @"', '" + txtPassword + @"', '" + txtFullName + @"',
'" + txtHomePhone + @"', '" + txtPhoneToCall + @"',
'" + txtCompanyEmail + @"', '" + txtPersonalEmail + @"',
" + cbxIsManager + ");";
int cnt = mysql.ExecuteInsert(query);
仍在寻求帮助,因为我想使用 dapper....