Click here to Skip to main content
15,569,858 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have this forms not executing in accordance with the codes , here I attached the class-forms and database connection as well .


1- EMPL cLASS
https://drive.google.com/file/d/16AtUt-3...sp=sharing
2- eMPLOYEE info form

https://drive.google.com/file/d/1bJl22fi...sp=sharing

3- form employee

https://drive.google.com/file/d/1-5P4jkf...sp=sharing
4- DbEmployee
https://drive.google.com/file/d/1OPoRbMR...sp=sharing

What I have tried:

I have this forms not executing in accordance with the codes , here I attached the class-forms and database connection as well .
Posted
Updated 30-Aug-22 22:43pm
Comments
Richard MacCutchan 30-Aug-22 5:02am    
Please remove the Google drive links from your question, as none of them exist. If you have information that helps to clarify your problem then add it to the question.

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

JUst dumping your whole project on us and saying "not executing" doesn't help anyone.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
THANKS FOR YOUR REPLY , basically i created this class and database connection plus forms whoever i click the save button it dosenot executed , maybe to null values i added into the statement :
THIS THE CONNECTION
1- DBeMPLOYEE:
C#
string sql = "INSERT INTO employee_table VALUES(@EmpName,@RegNo,@Job_Tile,@Position,@Hiring_Date,@Country,@Birthdate,@Gender,@Phone,@Address,@Photo,@DeptId,NULL)";

2- THIS INSERT statement in the form where we want to execute through click "save" :

C#
string query ="INSERT INTO employee_table(EmpName,RegNo,Job_Title,Position,Hiring_Date,Country,Birthdate,Gender,Phone,Address,Photo,DeptID)Values('" + this.textBox_EmpName.Text + "','" + this.textBox_JopTitle.Text + "','" + this.textBox_Position.Text + "','" + this.comboBox_Dept.Text + "','" + this.Cbox_Country.Text + "','" + this.textBox_Hiringdate.Text + "','" + this.textBox_phone.Text + "','" + this.textBox_RegNo.Text + "','" + this.textBox_Birthdate.Text + "','" + this.textBox_Address.Text + "','" + this.pictureBox_employee.Image + "','" + this.pictureBox_employee.Image + "')";


so mayube this the issue in the statement ?
 
Share this answer
 
v2
Comments
Richard MacCutchan 30-Aug-22 4:08am    
"mayube this the issue in the statement ?"
I would suggest it is definitely in the statement. you should never use string concatenation to create SQL statements. Especially when you are accepting raw user input without any checks on its validity. You are trying to store all values as text which is probably wrong for some of the numerics, and definitely wrong for dates. You also have the column names in one order and the actual values in another.
Member 15751945 30-Aug-22 4:43am    
I change the dates into this :
string query ="INSERT INTO employee_table(EmpName,RegNo,Job_Title,Position,Hiring_Date,Country,Birthdate,Gender,Phone,Address,Photo,DeptID)Values('" + this.textBox_EmpName.Text + "','" + this.textBox_JopTitle.Text + "','" + this.textBox_Position.Text + "','" + this.comboBox_Dept.Text + "','" + this.Cbox_Country.Text + "','" + this.dateTimePicker_hd.Text + "','" + this.textBox_phone.Text + "','" + this.textBox_RegNo.Text + "','" + this.dateTimePicker_bd.Text+ "','" + this.textBox_Address.Text + "','" + this.pictureBox_employee.Image + "')";
Richard MacCutchan 30-Aug-22 5:00am    
It is still wrong in more ways than one. Look at the actual order of your column names against the order of your values. Do not use text strings to store data values. Do not use raw input (textbox.text) without validation. Dp not ever use string concatenation to create SQL statements. You must use proper parameterised queries or your code will never work safely.
Richard MacCutchan 30-Aug-22 6:20am    
And this is what you have created:
EmpName,		this.textBox_EmpName.Text
RegNo,			this.textBox_JopTitle.Text
Job_Title,		this.textBox_Position.Text
Position,		this.comboBox_Dept.Text
Hiring_Date,	this.Cbox_Country.Text
Country,		this.dateTimePicker_hd.Text
Birthdate,		this.textBox_phone.Text
Gender,			this.textBox_RegNo.Text
Phone,			this.dateTimePicker_bd.Text
Address,		this.textBox_Address.Text
Photo,			this.pictureBox_employee.Image
DeptID			???
Member 15751945 30-Aug-22 8:05am    
I retyped it to this :

EmpName this.textBox_EmpName.Text
RegNo this.textBox_RegNo
Job_Title this.textBox_JopTitle.Text
Position this.textBox_Position.Text
Hiring_Date this.dateTimePicker_hd.Text
Country this.Cbox_Country.Text
Birthdate this.dateTimePicker_bd.Text
Gender this.comboBox_Gender.Text
Phone this.textBox_phone.Text
Address this.textBox_Address.Text
Photo this.pictureBox_employee.Image
DeptID this.comboBox_Dept.Text

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900