c# - Conversion failed when converting date and or time from character string -


i getting error

conversion failed when converting date , or time character string

when perform following insert c# code:

private void updatelatestdatetimeontable(string status,                                           datetime starttime,                                           datetime completetime) {     var command = $"insert  {datamallproxydbaccessor.proxysynchistorytable}" + " " + " values" + " " +                 "(" +                 $"'@id'," +                 $"'@status'," +                 $"'@starttime'," +                 $"'@completetime'" +                 ")";      var sqlcommand = new sqlcommand(command)             {                 connection = _proxydbconnection,                 transaction = _datamallsqltransaction             };      sqlcommand.parameters.addwithvalue("@id", guid.newguid());     sqlcommand.parameters.addwithvalue("@status", status);     sqlcommand.parameters.addwithvalue("@starttime", sqldbtype.datetime).value = starttime.tostring("yyyy-mm-dd hh:mm:ss");     sqlcommand.parameters.addwithvalue("@completetime", sqldbtype.datetime).value = completetime.tostring("yyyy-mm-dd hh:mm:ss");      sqlcommand.executenonquery(); } 

any suggestions on doing wrong here ?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -