哪位前辈做过从SQLServer数据库读取varbinary的数据?
我从数据库读取Varbinary的数据使用SqlDataReader对象接收,调用对象的Read()方法时抛出了这样的信息:从数据类型varbinary转换为numeri...
我从数据库读取Varbinary的数据使用SqlDataReader对象接收,调用对象的Read()方法时抛出了这样的信息:从数据类型 varbinary 转换为 numeric 时出错。代码如下:public Hashtable getPwdCard()
{
string sql = "select * from password_card where passwordCard = 1000010000000100009";
Hashtable ht = new Hashtable();
SqlDataReader sqldr = DBHelper.getOneLine(sql);
if (sqldr.Read()) //此处抛出的错误
{
byte[] bit = (byte[])sqldr["passwordCard"];
Stream stream = new MemoryStream();
stream.Position = 0;
stream.Read(bit, 0, bit.Length);
BinaryFormatter bitFormatter = new BinaryFormatter();
ht = (Hashtable)bitFormatter.Deserialize(stream);
}
sqldr.Close();
return ht;
} 展开
{
string sql = "select * from password_card where passwordCard = 1000010000000100009";
Hashtable ht = new Hashtable();
SqlDataReader sqldr = DBHelper.getOneLine(sql);
if (sqldr.Read()) //此处抛出的错误
{
byte[] bit = (byte[])sqldr["passwordCard"];
Stream stream = new MemoryStream();
stream.Position = 0;
stream.Read(bit, 0, bit.Length);
BinaryFormatter bitFormatter = new BinaryFormatter();
ht = (Hashtable)bitFormatter.Deserialize(stream);
}
sqldr.Close();
return ht;
} 展开
2013-07-28
展开全部
插入
insert into tableName(item) values(convert(varbinary(200),'11111'))
查询
select convert(varchar(200),item) as test from tableName
item是字段名 用string代替
insert into tableName(item) values(convert(varbinary(200),'11111'))
查询
select convert(varchar(200),item) as test from tableName
item是字段名 用string代替
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询