Sheepeemporgo
New Member
When the date is entered in the textbox in the format \[code\]DD/MM/YYYY\[/code\] if the day is earlier than 12 it is stored as \[code\]MM/DD/YYYY\[/code\]. I need it to be stored as typed.\[code\]protected void InsertButton_Click(object sender, EventArgs e){ Int32 claim = (Int32)Session["Claim"]; string claim1 = Convert.ToString(claim); Label4.Text = "Claim Number : " + (String)claim1; Label4.Visible = true; // declare variables to hold info enterend by user string expenseType; string purpose; decimal amount; DateTime date; Boolean receipts; //assign info entered to variables entered above expenseType = DropDownList1. Text; purpose = PurposeofExpenseTextBox.Text; amount = Convert.ToDecimal(AmountSpentTextBox.Text); date = Convert.ToDateTime(DatePurchasedTextBox.Text); receipts = CheckBox1.Checked; DateTime today = DateTime.Today; // create connection string "conn" string mapPath = Server.MapPath("."); string ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" + @"Data source= "*****"; OleDbConnection conn = new OleDbConnection(ConnectionString); try { //create query to insert values into Expenses table OleDbCommand cmd = new OleDbCommand("INSERT INTO Expenses (ExpenseType, PurposeofExpense, AmountSpent, DatePurchased, strEmpName, Receipts, EmployeeID, ExpNumber) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", conn); cmd.Parameters.Add("@ExpenseType", OleDbType.VarChar).Value = http://stackoverflow.com/questions/15764152/DropDownList1.Text; cmd.Parameters.Add("@PurposeofExpense", OleDbType.VarChar).Value = http://stackoverflow.com/questions/15764152/PurposeofExpenseTextBox.Text; cmd.Parameters.Add("@AmountSpent", OleDbType.VarChar).Value = http://stackoverflow.com/questions/15764152/AmountSpentTextBox.Text; cmd.Parameters.Add("@DatePurchased", OleDbType.VarChar).Value = http://stackoverflow.com/questions/15764152/DatePurchasedTextBox.Text; cmd.Parameters.Add("@strEmpName", OleDbType.VarChar).Value = http://stackoverflow.com/questions/15764152/(String)Session["New"]; cmd.Parameters.Add("@Receipts", OleDbType.Boolean).Value = http://stackoverflow.com/questions/15764152/CheckBox1.Checked; cmd.Parameters.Add("@EmployeeID", OleDbType.VarChar).Value = http://stackoverflow.com/questions/15764152/(String)Session["Number"]; cmd.Parameters.Add("@ExpNumber", OleDbType.VarChar).Value = http://stackoverflow.com/questions/15764152/(Int32)Session["Claim"]; //open connection "conn" conn.Open(); //execute insert query cmd.ExecuteNonQuery();\[/code\]