Hi
I'm not sure if this is a VB question or an SQL server question but here goes...
I have a db created in SQL Server 2000 with a VB.net interface and I am tring to input a date. The datatype is datetime and I have code that corrects a typo if the date is not valid. I even put in msgbox to tell me what me code and the system is doing - first it tells me the systems date Now() and then tells me the value of the textbox so that either would be valid entries, but then when I look at the entry in the database no matter what is entered it puts in 1/1/1900 as the date - what the heck is that?! Here is the peice of code, any advice will help.
***Date verification***
If IsDate(textdate.Text) Then
textdate.Text = FormatDateTime(textdate.Text, DateFormat.ShortDate)
Else
textdate.Text = FormatDateTime(Now(), DateFormat.ShortDate)
EndIf
***SQL statement***
Dim str AsString = "insert demographic(accnum, clinic, qdate) values (" & _
acc & "," & _
preparestr(textclinic.Text) & "," & _
textdate.Text & ")"
mycommand = New SqlCommand(str, myconnection)
mycommand.ExecuteNonQuery()
Thanks.
I'm not sure if this is a VB question or an SQL server question but here goes...
I have a db created in SQL Server 2000 with a VB.net interface and I am tring to input a date. The datatype is datetime and I have code that corrects a typo if the date is not valid. I even put in msgbox to tell me what me code and the system is doing - first it tells me the systems date Now() and then tells me the value of the textbox so that either would be valid entries, but then when I look at the entry in the database no matter what is entered it puts in 1/1/1900 as the date - what the heck is that?! Here is the peice of code, any advice will help.
***Date verification***
If IsDate(textdate.Text) Then
textdate.Text = FormatDateTime(textdate.Text, DateFormat.ShortDate)
Else
textdate.Text = FormatDateTime(Now(), DateFormat.ShortDate)
EndIf
***SQL statement***
Dim str AsString = "insert demographic(accnum, clinic, qdate) values (" & _
acc & "," & _
preparestr(textclinic.Text) & "," & _
textdate.Text & ")"
mycommand = New SqlCommand(str, myconnection)
mycommand.ExecuteNonQuery()
Thanks.