Unable to insert DateTime format into database
- by melvg
I'm unable to insert the DateTime into my database. Am i writing the statement wrongly?
Apparently without the DateTime, I am able to insert into the database
    string dateAndTime = date + " " + time;
    CultureInfo provider = CultureInfo.InvariantCulture;        
    DateTime theDateTime = DateTime.ParseExact(dateAndTime, "d MMMM yyyy hh:mm tt", provider);
//Create a connection, replace the data source name with the name of the SQL Anywhere Demo Database that you installed
            SAConnection myConnection = new SAConnection("UserID=dba;Password=sql;DatabaseName=emaDB;ServerName=emaDB");
            //open the connection 
            ; myConnection.Open();
            //Create a command object. 
            SACommand insertAccount = myConnection.CreateCommand();
            //Specify a query. 
            insertAccount.CommandText = ("INSERT INTO [meetingMinutes] (title,location,perioddate,periodtime,attenders,agenda,accountID,facilitator,datetime) VALUES ('"+title+"','" + location + "', '" + date + "','" + time + "', '" + attender + "','" + agenda + "', '" + accountID + "','" + facilitator + "','" +theDateTime+ "')");
try
    {
        insertAccount.ExecuteNonQuery();
        if (title == "" || agenda == "")
        {
            btnSubmit.Attributes.Add("onclick", "displayIfSuccessfulInsert();");
            //ScriptManager.RegisterStartupScript(this, GetType(), "error", "alert('Please ensure to have a title or agenda!');", true);
        }
        else
        {
            btnSubmit.Attributes.Add("onclick", "displayIfSuccessfulInsert();");
            Response.Redirect("HomePage.aspx");
            //ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", "alert('Minutes Created!'); window.location='" + Request.ApplicationPath + "/HomePage.aspx';", true);
        }
    }
    catch (Exception exception)
    {
        Console.WriteLine(exception);
    }
    finally 
    {            
        myConnection.Close();          
    }
It does not insert the SQL into my database.