Welcome to Macrobject Community Login | Register | Faq  

    Macrobject Community
  Macrobject Software Knowledge Management and Collaboration Platform
Search    
   

Re: 如何将String与Byte()进行转换
Started by TearCry at 07-11-2009 5:24 AM. Topic has 2 replies.

Print Search
  07-11-2009, 5:24 AM
TearCry is not online. Last active: 7/12/2009 12:23:31 PM TearCry

Top 75 Posts
Joined on 07-11-2009
Posts 2
如何将String与Byte()进行转换
Reply Quote
数据库使用SQL Server,
我的一个表Path中有个字段,Flag, 数据类型为Image 二进制
经过CodeAuto生成代码后,按String类型存储

我读取文件为Byte数组,将其转换为String

Dim p As New Path(om)

Byte() content是读取到的文件内容,然后利用

p.Flag = Convert.ToBase64String(content)
p.save()
产生错误String 转换为Byte() 出错,请问是怎么回事?

难道Blob,Clob大字段都只能选择用String存储吗?


还有之前我用Access数据库,在用save()方法保存实体时,会报少分号的错误。
   Report 
  07-11-2009, 7:45 AM
Bill is not online. Last active: 12/18/2009 11:43:49 PM Bill

Top 10 Posts
Joined on 06-28-2008
Posts 15
Re: 如何将String与Byte()进行转换
Reply Quote
As your descriptions, date type of p.Flag should be byte[].
You must convert your content to byte[] before assign it to p.Flag. 根据你的描述,p.Flag 的数据类型应该是 byte[]。 你应该将内容转换成 byte[] 之后再给 p.Flag 赋值。
   Report 
  07-11-2009, 9:27 PM
TearCry is not online. Last active: 7/12/2009 12:23:31 PM TearCry

Top 75 Posts
Joined on 07-11-2009
Posts 2
Re: 如何将String与Byte()进行转换
Reply Quote
可是PathType这个类里的Flag属性是String类型的

您的竟然可以是这样?
Dim pt as New PathType(om)
Dim content as Byte() = ....(从文件获取)

pt.Flag = content
pt.Save()

Byte()怎么能直接赋给String类型的属性呢?
我就是把Byte()转换为String再给Flag属性的,可是这样就报错了,详细的异常信息等我之后贴出来。

啊,等我上班时候我详细的代码贴上来再讨论吧。
不管怎么样,还是谢谢您。
   Report 
Post
Macrobject Comm... » Developing Tool... » NObject O/R Map... » Re: 如何将String与Byte()进行转换

Powered by Community Server, by Telligent Systems