c# - Inserting date into database when we insert data to database every time display inserting date in asp.net -


when inserting data database need insert date pass insert query in query inserted data took date column default sql database date format want display when user enter data insert data base date want display tried query is:

string s = "insert batchpermissons(batchid,subjectid,auditoname,audioid,createdby,createddate) values(" + batchno + ", " + subjectid + " , '" + audiotoname + "', " + audioid + ",'" + cby + "'," + datetime.now.tostring() + ")"; sqlcommand cmd = new sqlcommand(s, con); cmd.commandtype = commandtype.text; cmd.connection = con; con.open(); cmd.executenonquery(); con.close(); 

but above query inserting default date in database.i need insert when insert data particular date store can 1 me out.

you can replace datetime.now.tostring() "getdate()". take date sql server. or add format tostring

datetime.now.tostring("yyyy-mm-dd hh:mm:ss"); 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -