K
Khurram
I have a problem while inserting time value in the datetime Field.
I want to Insert only time value in this format (08:15:39) into the SQL
Date time Field.
I tried to many ways, I can extract the value in timeonly format by using
this command
Format(now,"HH:mm:ss")
But when I insert it into the Sql Server database, it embadded date value
with it.
the output looks like that "01/01/1900 08:59:00" in that case time is
correct but date is picked up by default, but I don't even want to have date
along with time. and If I want then I already passed the Current Date, so
the current date should be displayed, but why it is displaying the default
date "01/01/1900".
More over I checked to insert the simple current date into the database
with the Insert command, but it still inserts the Default date.
Here is my complete code.
Dim sqlconn As New SqlConnection("Data Source =MSC RHD SERVER;user id
=sa;pwd=testserver;initial catalog = testData")
Dim Sqlcom As New SqlCommand
Try
sqlconn.Open()
Dim m_sql As String
m_sql = "Insert into Logcomms (recdate)"
m_sql = m_sql & " values (" & DateTime.Today & ")"
'MsgBox(m_sql)
Sqlcom.Connection = sqlconn
Sqlcom.CommandText = m_sql
Dim M_result As Integer = Sqlcom.ExecuteNonQuery
Catch ex As Exception
MsgBox(ex.ToString)
Finally
sqlconn.Dispose()
Sqlcom.Dispose()
End Try
*Please Help me it is Urgent. I am new bee in VB.NET
Thanks in Advance
Khurram
I want to Insert only time value in this format (08:15:39) into the SQL
Date time Field.
I tried to many ways, I can extract the value in timeonly format by using
this command
Format(now,"HH:mm:ss")
But when I insert it into the Sql Server database, it embadded date value
with it.
the output looks like that "01/01/1900 08:59:00" in that case time is
correct but date is picked up by default, but I don't even want to have date
along with time. and If I want then I already passed the Current Date, so
the current date should be displayed, but why it is displaying the default
date "01/01/1900".
More over I checked to insert the simple current date into the database
with the Insert command, but it still inserts the Default date.
Here is my complete code.
Dim sqlconn As New SqlConnection("Data Source =MSC RHD SERVER;user id
=sa;pwd=testserver;initial catalog = testData")
Dim Sqlcom As New SqlCommand
Try
sqlconn.Open()
Dim m_sql As String
m_sql = "Insert into Logcomms (recdate)"
m_sql = m_sql & " values (" & DateTime.Today & ")"
'MsgBox(m_sql)
Sqlcom.Connection = sqlconn
Sqlcom.CommandText = m_sql
Dim M_result As Integer = Sqlcom.ExecuteNonQuery
Catch ex As Exception
MsgBox(ex.ToString)
Finally
sqlconn.Dispose()
Sqlcom.Dispose()
End Try
*Please Help me it is Urgent. I am new bee in VB.NET
Thanks in Advance
Khurram