2017-07-25 42 views
1

我正在將一個時間值(例如18:30 - 西班牙格式)存儲在一個sql-server 2014數據庫中(dtHoraInicio)被定義爲(time(0),NULL),插入的工作和數據保存得很好經典ASP:試圖顯示存儲在「(時間(0),NULL)sql服務器字段中的時間

在我的網頁中,我只是想顯示值:

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

,我得到這個錯誤:

Microsoft Cursor Engine error '80020009' 

Multiple-step operation generated errors. Check each status value

我改變了訪問返回到該數據的方式:

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") 
'------------------------ 

而且我得到這個新的錯誤:

ADODB.Recordset error '800a0bb9' 

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

如果我嘗試在本地/測試環境來執行它,它的作品完美,從本地連接到生產數據庫也沒有問題,但是現在我將文件上傳到生產環境,代碼失敗。所以我不知道這是代碼問題還是來自數據庫配置。

如果我在sql-server Management Studio中執行查詢,它將完美運行並顯示所有數據,而不會出現任何問題。

有什麼想法?

非常感謝你提前

+0

對不起,生產中使用的連接是:「Driver = {SQL Server}; Provider = SQLNCLI11.1; xxxxxxxxxxx; database = xxxxxxxx; uid = xxxxxxxx; pwd = xxxxxxxx」和來自本地I'沒有提供者的連接和它的工作原理,但IT團隊告訴我他們不能改變連接的方式,所以我的問題是爲什麼提姆電子類型不能用OLEDB識別?謝謝 – euno

+1

我們知道了,最後我們把時間字段轉換爲查詢中的varchar,然後將其顯示在頁面上。如果你願意,你可以刪除這個問題(我沒有找到方法)或者離開它,也許對某個人有用。問候。 – euno

+0

這是有效的問題和答案,請將解決方案作爲自己的答案發布。 :) –

回答

0

解決方案:

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

其中 「時間」(時間(0)空)類型字段,我轉換爲varchar(5),因爲在西班牙時間格式爲hh:mm