TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bendaoud achraf
NA
3
653
exception in Mysql.data.dll
Jun 21 2016 9:49 AM
hello,
i'm working on a forms application where i need to insert data into mysql db and here's the code:
public const string query = "INSERT INTO facturation (Projet,N-facture,Total-HT,Retenue-garantie-10%,Retenue-avance,Montant-HT,TVA,TTC,Payement1,Date1,Payement2,Date2,Payement3,Date3,Payement4,Date4) VALUES (@Projet,@N-facture,@Total-HT,@Retenue-garantie-10%,@Retenue-avance,@Montant-HT,@TVA,@TTC,@Payement1,@Date1,@Payement2,@Date2,@Payement3,@Date3,@Payement4,@Date4)";
using (MySqlConnection conn = new MySqlConnection(Datacon.con))
{
int Nfacture = 1;
float TotalHT = 1;
float Retenuegarantie10 = 1;
float Retav = 1;
float MontHT = 1;
float TVA = 1;
float TTC = 1;
float P1 = 1;
float P2 = 1;
float P3 = 1;
float P4 = 1;
DateTime D1 = DateTime.Now.Date;
DateTime D2 = DateTime.Now.Date;
DateTime D3 = DateTime.Now.Date;
DateTime D4 = DateTime.Now.Date;
MySqlCommand com = new MySqlCommand(Datacon.query, conn);
f2 f21 = new f2();
com.Parameters.AddWithValue("@Projet", f21.textBox1.Text);
com.Parameters.AddWithValue("@N-facture", int.TryParse(f21.textBox2.Text,out Nfacture));
com.Parameters.AddWithValue("@Total-HT", float.TryParse(f21.textBox3.Text,out TotalHT));
com.Parameters.AddWithValue("@Retenue-garantie-10%", float.TryParse(f21.textBox4.Text,out Retenuegarantie10));
com.Parameters.AddWithValue("@Retenue-avance", float.TryParse(f21.textBox5.Text,out Retav));
com.Parameters.AddWithValue("@Montant-HT", float.TryParse(f21.textBox6.Text,out MontHT));
com.Parameters.AddWithValue("@TVA", float.TryParse(f21.textBox7.Text,out TVA));
com.Parameters.AddWithValue("@TTC", float.TryParse(f21.textBox8.Text,out TTC));
com.Parameters.AddWithValue("@Payement1", float.TryParse(f21.textBox9.Text,out P1));
com.Parameters.AddWithValue("@Date1", DateTime.TryParse(f21.textBox10.Text,out D1));
com.Parameters.AddWithValue("@Payement2", float.TryParse(f21.textBox11.Text,out P2));
com.Parameters.AddWithValue("@Date2", DateTime.TryParse(f21.textBox12.Text,out D2));
com.Parameters.AddWithValue("@Payement3", float.TryParse(f21.textBox13.Text,out P3));
com.Parameters.AddWithValue("@Date3", DateTime.TryParse(f21.textBox14.Text,out D3));
com.Parameters.AddWithValue("@Payement4", float.TryParse(f21.textBox15.Text,out P4));
com.Parameters.AddWithValue("@Date4", DateTime.TryParse(f21.textBox16.Text, out D4));
conn.Open();
try {
com.ExecuteNonQuery();
MessageBox.Show("sauvegarde remplie!");
}catch(MySqlException )
{
MessageBox.Show("Erreur!");
}
conn.Close();
}
}
the exception is thrown in com.ExecuteNonQuery(); as you would have guessed
please advise
Reply
Answers (
1
)
Conversion from structure to byte array & object to byte arr
parse profile JSON c#