Click here to Skip to main content
15,905,028 members
Home / Discussions / C#
   

C#

 
AnswerRe: Datatable Pin
_mubashir5-Apr-07 20:53
_mubashir5-Apr-07 20:53 
AnswerRe: Datatable Pin
Harini N K6-Apr-07 0:32
Harini N K6-Apr-07 0:32 
QuestionHelp!!! Declare a varied-length array of structures and the use of marshalling? Pin
peary5-Apr-07 18:21
peary5-Apr-07 18:21 
AnswerRe: Help!!! Declare a varied-length array of structures and the use of marshalling? Pin
Luc Pattyn6-Apr-07 4:50
sitebuilderLuc Pattyn6-Apr-07 4:50 
QuestionC# Pin
rednexhex5-Apr-07 16:59
rednexhex5-Apr-07 16:59 
AnswerRe: C# Pin
Sathesh Sakthivel5-Apr-07 17:12
Sathesh Sakthivel5-Apr-07 17:12 
AnswerRe: C# Pin
Rudolf Jan6-Apr-07 0:30
Rudolf Jan6-Apr-07 0:30 
QuestionCall an Executable from C# with Administrative rights Pin
ke3p_up5-Apr-07 16:40
ke3p_up5-Apr-07 16:40 
AnswerRe: Call an Executable from C# with Administrative rights Pin
shrinerainxp5-Apr-07 21:26
shrinerainxp5-Apr-07 21:26 
GeneralRe: Call an Executable from C# with Administrative rights Pin
ke3p_up5-Apr-07 22:41
ke3p_up5-Apr-07 22:41 
Questionsockets question Pin
dino20945-Apr-07 15:45
dino20945-Apr-07 15:45 
QuestionGeneric collection classes with Hashtable Pin
sreecahitu5-Apr-07 13:38
sreecahitu5-Apr-07 13:38 
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 

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.