Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Insert date into datetime field problem with sql 2000


Message #1 by Philip Tham <philipt1@s...> on Tue, 18 Mar 2003 11:10:29 -0600
Can someone help me out a little?

Problem: received 1900-01-01 00:00:00.000 inserted into the table...How to
resolve this?

In sql version 7 by sending "'" & Now & "'" will work fine

Here is my codes:

              DBInsert.CommandText = "Insert Into ActivityProgressHistory "
_
                 & "(User_id, Activity_id, Question_id, HowManyCorrect,
HowManyWrong, ProgressDate)" _
                 & "values (" _
                 & UserID & ", " _
                 & Request.QueryString("Activity") & ", " _
                 & Request.QueryString("Question") & ", " _
                 & TotalCorrectH.Value & ", " _
                 & CINT(MaxAttemptH.Value)-TotalCorrectH.Value & ", " _
                 & DateTime.Today & ")"
              DBInsert.Connection = DBConn
              DBInsert.Connection.Open
              DBInsert.ExecuteNonQuery()


Thanks in advance!

Philip

Message #2 by "Peter Lanoie" <planoie@n...> on Tue, 18 Mar 2003 14:00:06 -0500
Instead of having VB generate the date you could just have SQL do it...

Change: 
	& DateTime.Today & ")"
To:
	& "GETDATE())"

Peter

-----Original Message-----
From: Philip Tham [mailto:philipt1@s...]
Sent: Tuesday, March 18, 2003 12:10
To: ASP.NET
Subject: [aspx] Insert date into datetime field problem with sql 2000


Can someone help me out a little?

Problem: received 1900-01-01 00:00:00.000 inserted into the table...How to
resolve this?

In sql version 7 by sending "'" & Now & "'" will work fine

Here is my codes:

              DBInsert.CommandText = "Insert Into ActivityProgressHistory "
_
                 & "(User_id, Activity_id, Question_id, HowManyCorrect,
HowManyWrong, ProgressDate)" _
                 & "values (" _
                 & UserID & ", " _
                 & Request.QueryString("Activity") & ", " _
                 & Request.QueryString("Question") & ", " _
                 & TotalCorrectH.Value & ", " _
                 & CINT(MaxAttemptH.Value)-TotalCorrectH.Value & ", " _
                 & DateTime.Today & ")"
              DBInsert.Connection = DBConn
              DBInsert.Connection.Open
              DBInsert.ExecuteNonQuery()


Thanks in advance!

Philip



  Return to Index