Hello everyone.
Based on Erel's reply (post #2) from https://www.b4x.com/android/forum/threads/datetime.119969/post-750103:
I am triyng to insert a record into a MS SQL Server database table via JRDC2. The table has four columns:
id (tinyint) channel(tinyint) period_start (datetime2(0)) count(smallint) value(float).
I'm sending a ticks value for the period_start column.
The insertion code is:
This insert fails with:
Inserting with the datetime as a string ("yyyy-MM-dd HH:mm:ss") works. But querying datetime2(0) columns returns ticks, so I'd like to keep it as ticks all the way through.
Do I have to insert the datetime2(0) as a string, or can it be done as ticks?
Thanks.
Based on Erel's reply (post #2) from https://www.b4x.com/android/forum/threads/datetime.119969/post-750103:
If you are using jRDC2 then you should send the ticks value (Long).
I am triyng to insert a record into a MS SQL Server database table via JRDC2. The table has four columns:
id (tinyint) channel(tinyint) period_start (datetime2(0)) count(smallint) value(float).
I'm sending a ticks value for the period_start column.
The insertion code is:
InsertData:
Public Sub InsertLoggedData As ResumableSub
Dim lstCommands As List
lstCommands.Initialize
Dim comInsert As String = "insert_loggeddata"
Dim cmdInsert As DBCommand = CreateCommand(comInsert, Array(1, 1, DateTime.now, 10, 1))
lstCommands.Add(cmdInsert)
Dim j As HttpJob = CreateRequest.ExecuteBatch(lstCommands, Null)
Wait For(j) JobDone(j As HttpJob)
If j.Success Then
Log("InsertInto LoggedData successful")
Else
Log("InsertInto LoggedData failed: " & LastException)
End If
j.Release
Return j.Success
This insert fails with:
Log:
ResponseError. Reason: com.microsoft.sqlserver.jdbc.SQLServerException: Operand type clash: bigint is incompatible with datetime2, Response: .....
Inserting with the datetime as a string ("yyyy-MM-dd HH:mm:ss") works. But querying datetime2(0) columns returns ticks, so I'd like to keep it as ticks all the way through.
Do I have to insert the datetime2(0) as a string, or can it be done as ticks?
Thanks.