How can i do when i insert date to sqlserver it also error?
Hi all!
i use sqlserver for database and vb.net as interface.
when i insert datetime to the column that has format datetime it is also error.
when the datetime format of system is "dd/mm/yyyy hh:mm:ss".
but if system datetime format is 'mm/dd/yyyy hh:mm:ss' it is not error.
so what sould i do if i do not to change the system datetime format?
please Help me?
best regards,
thirith.
Re: How can i do when i insert date to sqlserver it also error?
Hi !
What are you using to update your database ? SQL "INSERT INTO" Statement or DataAdaptor with DataSet ?
Re: How can i do when i insert date to sqlserver it also error?
try to format it this way before putting the date in your sql statement :
VB Code:
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
should work whatever regional settings you have.
Re: How can i do when i insert date to sqlserver it also error?
Hi !
thanks when i try to use format as "yyyy-MM-dd HH:mm:ss" before i insert date to sqlserver thruogh INSERT statment.
OK Bye.
Thirith
Re: How can i do when i insert date to sqlserver it also error?
Throught SQL Statement i've coem to a problem similar and the fax i've found is to convert de date to a double and reconvert it to date on the SQL Serer side
Like this:
VB Code:
strsql = "INSERT INTO tblTable (Id, TheDate, Notes) VALUES (1, Convert(DateTime, " & dtDate.ToOADate - 2 & ", 'The notes...'))"
In this way, no mater the date format it will work perfecly :p