源程序如下:
Set rs= Server.CreateObject("ADODB.Recordset")
SQL="SELECT CAST(item AS nvarchar(4000)) as bb FROM ITEMS WHERE NAME = 'jimmy'
rs.open SQL,conn2,1,1
response.write jx
Response.ContentType="application/msword"
Response.BinaryWrite rs("bb")
無論怎么弄,都顯示的是亂碼!!瘋了一天一夜了!100分求方法!!
使用getChunk的話,總提示在此環境中不允許操作!
我要瘋了!!拜托各位大蝦們,幫我解決一下吧!謝謝了!
17 个解决方案
response.write jx
Response.BinaryWrite rs("bb")
這兩個不能同時用吧。
[個人意見,僅供參考]
<img src="*.asp">
*.asp里面就是你的圖片顯示代碼。
想同時Response.BinaryWrite 和response.write我認為不大可能。
response.write jx 這是我調試的時候顯示Session,為了放數據庫能夠動態查找
varbinary 字段內的數據如下:
0x02940200000000000108AF2F01000000000000000000000000000000000000000000000000E2E001
定義的是Varbinary(2000)
各位大蝦~~幫忙了~~謝謝!!!
asp 中如何正常顯示上面的數據?
不會是沒人知道這個問題的解決方法吧?
哪怕是誰告訴我如何做一個存儲過程將數據先讀到臨時表里,並轉換后,再通過asp讀取呢~~
拜托~~幫忙誰告訴我啊?
以下這兩個資料或許對你有幫助~!你看一下吧~! :) 加油~! 完成了別忘了把經驗發出來~!
http://topic.csdn.net/t/20041023/11/3483837.html
關於MSSQL中的16進制數轉CHAR的解決方法
在ITPUB上看到一個關於16進制轉CHAR字段的問題
如何16進制to文本
declare @hex binary(2) , @show_hex char(4)
select @hex = 0x4E2D
如何實現 select @show_hex =???
使得結果顯示出: 4E2D
或者說 @show_hex ='4E2D'
我查看了SQL中的函數,並沒有找到轉換函數
然后用cast或convert函數直接轉換
declare @hex binary(2)
select @hex = 0x1F84 select convert(nvarchar(100),@hex)
----------------
萟
(所影響的行數為 1 行)
select convert(varchar(100),@hex)
----------------
(所影響的行數為 1 行)
結果另人失望,NCHAR得到亂碼,而CHAR的到空結果 隨后我嘗試16進制轉10進制
----------------
8068
(所影響的行數為 1 行)
根據這個方法,我寫了一個函數 16進制-->10進制-->再轉CHAR的方法
if exists(select * from dbo.sysobjects where name='FunHex' and type=N'FN')
drop function FunHex
GO
create function FunHex(@hex binary(2))
returns varchar(20) as begin
declare @return varchar(20),@num int
select @return='',@num=cast(@hex as int)
declare @tb table(Hs varchar(1),Hn int)
insert into @tb select 'A',10 union all select 'B',11 union all select 'C',12 union all select 'D',13 union all select 'E',14 union all select 'F',15
while @num>15 begin
set @return= case when (select hs from @tb where Hn=@num%16) is null then cast(@num%16 as varchar(1)) else (select hs from @tb where Hn=@num%16) end+@return
select @num=@num/16 end
set @return= case when (select hs from @tb where Hn=@num%16) is null then cast(@num%16 as varchar(1)) else (select hs from @tb where Hn=@num%16) end+@return return @return end GO
--調用
declare @hex binary(2)
select @hex = 0x1F84
select @hex
select dbo.funhex(@hex)
--結果
------
0x1F84
(所影響的行數為 1 行)
--------------------
1F84
(所影響的行數為 1 行)
關鍵是,我不知道如何才能存到一個新表里.可否告訴我???
declare @b varbinary(2000), @str varchar(2000)
select @b = item from char where name='測試用戶'
exec master..xp_varbintohexstr @b, @str out
print @str
將@Str存到新表里....
CSDN真的就沒有高手存在了么???已經好幾天了。
還是那句話, 建議把二進制數據 base64 后入庫. 先看懂這句話,再說......
幫幫忙,我找了很多的資料,但是都沒有很詳細的介紹。
麻煩你好人做到底,寫一個asp的例子給我好嗎?
謝謝了!!!分不夠我可以繼續加!
情況是,數據庫里的數據是由一個程序寫進去的。。。。本身就是二進制的。
現在我想讀出來...郁悶