my code
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();
it gives me "Fatal error encountered during command execution."
when i do another insert query in another case it works great, the different is that here i have cbxIsManager as a bool and in the db is a tinyint(1) and in the other case all is strings
if i add "Allow User Variables=true;" then i dont get the exception but in the db all values are null (checked that he gets values)
using ASP.NET at this project, console at the other, both FW4, mysql is 6.somthing (think 3) the other code
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();
any help would be appreciated
thx, ariel
EDIT: when did this it worked
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);
still looking for help since i would like to use the dapper....
Try replacing the @
s with :
s. It seemed to work for me:
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);";