|
-
Apr 27th, 2005, 06:01 AM
#1
Thread Starter
Addicted Member
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.
-
Apr 27th, 2005, 08:11 AM
#2
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 ?
-
Apr 27th, 2005, 09:08 AM
#3
Addicted Member
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.
There are no stupid questions, but a whole bunch of dumb sayings !
Save time on database code, try DataLG !
-
Apr 28th, 2005, 12:39 AM
#4
Thread Starter
Addicted Member
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
-
Apr 28th, 2005, 07:13 AM
#5
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|