Classic ASP: Trying to show a time stored in a "(time(0) , NULL) sql server field

329 views Asked by At

I'm storing a time value (for example 18:30 - Spain format) in a sql-server 2014 Database from a classic asp web application. The field (dtHoraInicio) is defined as (time(0), NULL). The inserts work and the data is stored well.

In my web page I'm just trying to show the value:

response.write oRSC("dtHoraInicio") 'where oRSC is the recordset

and I get this error:

Microsoft Cursor Engine error '80020009' 

Multiple-step operation generated errors. Check each status value

I changed the way to access the data returned to this:

Conexion = "Driver={SQL Server};Server=xxxxxxxxxxx;Initial Catalog=yyyyyyyy;User Id=zzzzzzzz;Password=aaaaaaaaaaa"

Set objConexion = Server.CreateObject("ADODB.Connection")
objConexion.CommandTimeout=120
objConexion.ConnectionTimeOut = 120
objConexion.Open Conexion

Set oRSC=CreateObject("ADODB.Recordset")
oRSC.ActiveConnection = objConexion
oRSC.CursorType = 0 ' 1 adOpenKeyset
oRSC.CursorLocation = 3 'adUseClient
oRSC.LockType = 3 'adLockOptimistic
oRSC.Source = FiltrarCadena(ssqlC)
oRSC.Open

'------------------------
response.write oRSC("dtHoraInicio")
'------------------------

And I got this new error:

ADODB.Recordset error '800a0bb9' 

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

If I try to execute it in local/testing environment, it works perfect, also connecting from local to the production database is fine, but in the moment I upload the file to production, the code fails. So I don't know if it's a problem of the code or if comes from the database configuration.

If I execute the query in sql-server Management Studio it runs perfect and shows all the data without problems.

Any idea?

Thank you very much in advance

1

There are 1 answers

0
euno On

Solution:

SELECT convert(varchar(5), TIME) as TIME from <table>

Where "TIME" is (time(0) null) type field and I convert to varchar(5) because in Spain the time format is hh:mm