I am a secondary school student currently doing a software development project involving databases with have little to no knowledge of sql, and have so far sufficed using a guide book given to me, But I cannot shake this error. I have linked what are to me the required screenshots, but if I have left any out I would be glad to know. I have thoroughly searched for this error both on this website and others, and have decided this is either a different case then what normally creates this error, or my technical knowledge is so limited that I cannot tell this difference. I am aware that no doubt the code I have written is poor, but do not have the time for a complete revamp of everything.(I am not allowed to add on images directly to SO appears to have linked them below)
......
.......
........
......
.
Please have a look for a dumb school student, and if you have any other advice please give it if you would.
Thanks for the edit and formatting advice, as you can see I'm not really the smartest tool in the shed.
Code for the Method:
public static int AddNewOrder(string OrderAddress, DateTime OrderDate, int
CustID, String OrderDeliveryDate, bool Delivery)
{
using (SqlConnection connection = new
SqlConnection(_connectionString))
{
connection.Open();
string sqlQuery = string.Format("INSERT INTO [Order]
(OrderAddress, OrderDate, CustID, OrderDeliveryDate, Delivery)VALUES('{0}',
'{1}', '{2}', '{3}','{4}')", OrderAddress, OrderDate, CustID,
OrderDeliveryDate, Delivery);
SqlCommand insertCommand = new
SqlCommand(sqlQuery,connection);
int rowsAffected = insertCommand.ExecuteNonQuery();
connection.Close();
return rowsAffected;
}
}
Code Within the data entry form:
bool Delivery;
int CustID;
string Address;
DateTime OrderDate;
DateTime OrderDeliveryDate;
private void buttonCreateOrder_Click(object sender, EventArgs e)
{
Delivery = checkBoxDelivery.Checked;
CustID = int.Parse(textBoxCustID.Text);
Address = textBoxOrderAddress.Text;
OrderDate = DateTime.Now;
OrderDeliveryDate = dtpOrderDeadlinDate.Value;
int rowsAffected = DAL.OrderFirstFormDAL.AddNewOrder(Address, OrderDate, CustID, OrderDeliveryDate.ToString("yyyy-MM-dd HH:mm:ss"), Delivery);