Click here to Skip to main content
15,887,322 members
Home / Discussions / C#
   

C#

 
AnswerRe: Generic collection classes with Hashtable Pin
roel_v5-Apr-07 21:04
roel_v5-Apr-07 21:04 
AnswerRe: Generic collection classes with Hashtable Pin
roel_v5-Apr-07 21:07
roel_v5-Apr-07 21:07 
QuestionHow to empty a Text file? Pin
Khoramdin5-Apr-07 12:50
Khoramdin5-Apr-07 12:50 
AnswerRe: How to empty a Text file? Pin
Luc Pattyn5-Apr-07 12:57
sitebuilderLuc Pattyn5-Apr-07 12:57 
AnswerRe: How to empty a Text file? Pin
Rudolf Jan6-Apr-07 0:32
Rudolf Jan6-Apr-07 0:32 
Questionopen OR run File Pin
TAREQ F ABUZUHRI5-Apr-07 12:28
TAREQ F ABUZUHRI5-Apr-07 12:28 
AnswerRe: open OR run File Pin
Luc Pattyn5-Apr-07 12:37
sitebuilderLuc Pattyn5-Apr-07 12:37 
QuestionHex String Pin
AAKAra5-Apr-07 11:37
AAKAra5-Apr-07 11:37 
Hello,


I need to send selected items from the ListBox to the database field "keyrings" of datatype varbinary(128),
thelogic i used is to get the selected items from the Listbox and set the byte[] to 1 for the sected item,


//Keyrings
byte[] aGroup = new byte[1024];
string hexString;
for (int index = 0; index < SecurityGroups.Items.Count; index++)
{
if (SecurityGroups.Items[index].Selected)
aGroup[index] = 1;
}

I converted those byte[] to hexstring

hexString = ToString(aGroup);



and then send the value to the database

xmlelem = xmldoc.CreateElement("", "ATTRIBUTE", "");
atttribute = xmldoc.CreateAttribute("NAME");
atttribute.Value = "KeyRings";
xmlelem.SetAttributeNode(atttribute);
xmltext = xmldoc.CreateTextNode(hexString);
xmlelem.AppendChild(xmltext);
xmlelem4.AppendChild(xmlelem);




public static string ToString(byte[] bytes)
{

string hexString = "";
try
{
StringBuilder temp = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
temp.Append(bytes[i].ToString("X2"));
}
hexString = temp.ToString();
}
catch (Exception)
{
}
return hexString;
}

My aGroup array shows first 3 items selected as {1,1,1,0.0.0.0...,

I am having a problem in conversion from bytes to hexstring here...with the first 3 item selected in the listbox, i should get
0700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
instead i am getting 01010100000000000000....

Is there any problem with my conversion, Please suggest.
AnswerRe: Hex String Pin
Luc Pattyn5-Apr-07 12:44
sitebuilderLuc Pattyn5-Apr-07 12:44 
GeneralRe: Hex String Pin
AAKAra6-Apr-07 3:52
AAKAra6-Apr-07 3:52 
GeneralRe: Hex String Pin
Luc Pattyn6-Apr-07 4:11
sitebuilderLuc Pattyn6-Apr-07 4:11 
GeneralRe: Hex String Pin
AAKAra6-Apr-07 11:39
AAKAra6-Apr-07 11:39 
QuestionPDF Generation Tool Pin
RB@Emphasys5-Apr-07 10:33
RB@Emphasys5-Apr-07 10:33 
Questionhandle to process Pin
likefood5-Apr-07 8:16
likefood5-Apr-07 8:16 
AnswerRe: handle to process Pin
pbraun5-Apr-07 8:55
pbraun5-Apr-07 8:55 
GeneralRe: handle to process Pin
likefood5-Apr-07 13:22
likefood5-Apr-07 13:22 
Questionhow to code a administrator login page using C#.net and ASP.net 1.1 Pin
sudhanshuk3ito515-Apr-07 6:07
sudhanshuk3ito515-Apr-07 6:07 
AnswerRe: how to code a administrator login page using C#.net and ASP.net 1.1 Pin
Sathesh Sakthivel5-Apr-07 6:42
Sathesh Sakthivel5-Apr-07 6:42 
AnswerRe: how to code a administrator login page using C#.net and ASP.net 1.1 Pin
Not Active5-Apr-07 7:08
mentorNot Active5-Apr-07 7:08 
QuestionListBox Pin
AAKAra5-Apr-07 5:51
AAKAra5-Apr-07 5:51 
AnswerRe: ListBox Pin
kubben5-Apr-07 5:58
kubben5-Apr-07 5:58 
GeneralRe: ListBox Pin
AAKAra5-Apr-07 11:36
AAKAra5-Apr-07 11:36 
QuestionI don´t know how to access my components to the groupbox Pin
Ens805-Apr-07 5:50
Ens805-Apr-07 5:50 
AnswerRe: I don´t know how to access my components to the groupbox Pin
BoneSoft5-Apr-07 6:33
BoneSoft5-Apr-07 6:33 
GeneralRe: I don´t know how to access my components to the groupbox Pin
Ens805-Apr-07 7:56
Ens805-Apr-07 7:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.