急!!!这样的问题如何解决,关于byte位操作?

caoit 2004-08-04 03:31:15
byte[] byRight = new byte[256];
for( int i=0; i<this.cblOrgOper.Items.Count; i++ )
{
if( this.cblOrgOper.Items[i].Selected)
{
int iModuleID = HRM.CPublicFn.IntObjectToInt( this.cblOrgOper.Items[i].Value );
byRight[ iModuleID/8 ] |= ( byte )( 1<<( 7-iModuleID%8 ) );
}
}

我将byRight存入到数据库一binary字段。

在通过DataSet读出某条记录,怎么再取出这一binary字段的内容????
byte[]
...全文
174 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanbinghai 2004-08-04
  • 打赏
  • 举报
回复
foreach (DataRow DR_file in ds.Rows)应该为
foreach (DataRow DR_file in ds.Tables[0].Rows)
hanbinghai 2004-08-04
  • 打赏
  • 举报
回复
//单个我就不会取了,我只能把整个字段取出来,再拆分
dataSet ds=new dataSet();
dataAdapter da=new dataAdapter(command,conn)
da.fill(ds);
foreach (DataRow DR_file in ds.Rows)
{
System.Text.ASCIIEncoding st = new System.Text.ASCIIEncoding();
//DR_file[6]是要取的字段
bytes = st.GetBytes(DR_file[6].ToString());
}
caoit 2004-08-04
  • 打赏
  • 举报
回复
to: hanbinghai(海宁) ( )

是的
fancyhsq 2004-08-04
  • 打赏
  • 举报
回复
dataSet ds=new dataSet();
dataAdapter da=new dataAdapter(command,conn)
da.fill(ds)
bytes[0],bytes[1]就会存在da里面...
我这里啥都没有,所以可能漏叫一点东西啦..大概是这个样子!!!!!!!
hanbinghai 2004-08-04
  • 打赏
  • 举报
回复
你的意思是直接从数据库里取出bytes[0],bytes[1]的值?
而不是取出整个数组?
caoit 2004-08-04
  • 打赏
  • 举报
回复
bytes[0],bytes[1]的值怎么取?
hanbinghai 2004-08-04
  • 打赏
  • 举报
回复
byte [] bytes;
string strConn= "server = .; Integrated Security = SSPI ; database = electric";
SqlConnection Conn=new SqlConnection(strConn);
Conn.Open();
SqlCommand command=new SqlCommand();
command.Connection=Conn;
command.CommandText = "select content from hbh" ;
//简单起见,只取第一行的第一列
bytes = (byte [])command.ExecuteScalar();
caoit 2004-08-04
  • 打赏
  • 举报
回复
还没明白
张海霖 2004-08-04
  • 打赏
  • 举报
回复
一样取,只不过取得时候放在 生成图片等的函数中作参数就可以了.

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧