insert into Table1(C1, I2, D1) VALUES('eric', 1234, '12/10/2002')>I have a very simple insert that refuses to behave. The issue is the datetime field [eventdate] walking through the code the date is as we would expect, a system.datetime showing a value of say #12/10/2002#, however, after the insert the date in the table is 1/1/1900 12:00 AM :( The SQL user has full datareader/datawriter rights. I Was hoping someone here would see the err of my ways. The database is a remote SQL 2000 server (SP2) running on windows 2000. Eventdate is a datetime field in SQL. I have also tried using a character var on the VB side.
Private Sub AddNewRegistry() > > Dim strInsSQL As String > Dim RegistrantUID, iRegistryType As Integer > Dim datEvent As DateTime > > RegistrantUID = DeCrypt(Session("RegistrantUID")) > iRegistryType = cboRegistryTypes.Items(cboRegistryTypes.SelectedIndex).Value > datEvent = txtEventDate.Text > strInsSQL = "INSERT INTO Registry (RegistryName, RegistryDesc, EventDate, RegType_ID, Registrant_ID) " & _ > "Values ('" & _ > txtRegistryName.Text.Trim & "', '" & _ > txtRegistryDesc.Text.Trim & "', Cast(" & _ > datEvent & " as datetime) , " & _ > iRegistryType & ", " & _ > RegistrantUID & ")" > > Dim oCn As New SqlConnection(SQLcn.ConnectionString.ToString) > Dim dbComm As New SqlCommand(strInsSQL, oCn) > oCn.Open() > dbComm.ExecuteNonQuery() > oCn.Close() > ClearRegistryEntry() > 'BindGrid(Session("SORTFIELD"))3 > End Sub