Click here to Skip to main content
15,886,518 members
Home / Discussions / C#
   

C#

 
Questiondata akses to mySql using c# Pin
tian's emo24-Feb-12 2:52
tian's emo24-Feb-12 2:52 
AnswerRe: data akses to mySql using c# Pin
R. Giskard Reventlov24-Feb-12 5:32
R. Giskard Reventlov24-Feb-12 5:32 
GeneralRe: data akses to mySql using c# Pin
tian's emo25-Feb-12 1:28
tian's emo25-Feb-12 1:28 
AnswerRe: data akses to mySql using c# Pin
kid sister24-Feb-12 18:22
kid sister24-Feb-12 18:22 
QuestionCompress with java decompress with c# Pin
Hossein Khalaj24-Feb-12 2:46
Hossein Khalaj24-Feb-12 2:46 
AnswerRe: Compress with java decompress with c# Pin
Eddy Vluggen24-Feb-12 8:42
professionalEddy Vluggen24-Feb-12 8:42 
AnswerRe: Compress with java decompress with c# Pin
Bernhard Hiller26-Feb-12 20:32
Bernhard Hiller26-Feb-12 20:32 
QuestionReading Null values in a byte array Pin
si_6924-Feb-12 1:24
si_6924-Feb-12 1:24 
Hi All

I am trying to loop through a byte array (sample below) reading the values to then insert those into a database

I loop through keeping track of the position

byte[] data;
   long position=0;
   while (position < data.Length)
   {
       position = Conversion.Extract(data, out mydata, position);
       position = Conversion.Extract(data, out nextitem, position);
   }

   public static long Extract(byte[] message, out int variable, long position)
   {
       const int length = 4; // the length of an int

       if (message.Length >= position + length)
       {
           variable = BitConverter.ToInt32(message, (int)position);
           return position + length;
       }

       // there was a problem
       variable = 0;
       return -1;
   }


The data i have contains some null values, how can i extract these and successfully move onto the next value. At present if i come across a null value i dont know how to detect this and move onto the next item. Can anyone help at all

Thanks

Simon



6F 72 67 61 6E 69 73 61 74 69 6F 6E 49 64 3D 33
26 10 00 00 00 50 65 6F 70 6C 65 50 65 6F 70 6C
65 4C 69 6E 6B 6A 08 00 00 09 00 00 00 0E 00 00
00 53 65 6E 69 6F 72 50 65 72 73 6F 6E 49 64 0E
00 00 00 4A 75 6E 69 6F 72 50 65 72 73 6F 6E 49
64 11 00 00 00 53 65 6E 69 6F 72 50 65 72 73 6F
6E 4D 69 73 49 64 11 00 00 00 4A 75 6E 69 6F 72
50 65 72 73 6F 6E 4D 69 73 49 64 08 00 00 00 4C
69 6E 6B 54 79 70 65 16 00 00 00 50 61 72 65 6E
74 61 6C 52 65 73 70 6F 6E 73 69 62 69 6C 69 74
79 08 00 00 00 50 72 69 6F 72 69 74 79 0B 00 00
00 4C 61 73 74 55 70 64 61 74 65 64 07 00 00 00
44 65 6C 65 74 65 64 01 00 00 00 D7 0A 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 01 80 C3 29
C6 85 BF CE 08 00 02 00 00 00 3C 0C 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 F0 83 76 C6
85 BF CE 08 00 03 00 00 00 3C 0C 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 C0 0E 76 C6 85
BF CE 08 00 04 00 00 00 67 0B 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 01 70 CA 4B C6 85 BF
CE 08 00 05 00 00 00 67 0B 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 02 70 CA 4B C6 85 BF CE
08 00 06 00 00 00 9B 08 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 02 C0 BE B2 C5 85 BF CE 08
00 06 00 00 00 AD 09 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 02 10 6D F5 C5 85 BF CE 08 00
06 00 00 00 3F 0A 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 02 80 59 11 C6 85 BF CE 08 00 07
00 00 00 E3 0A 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 01 C0 D0 2C C6 85 BF CE 08 00 08 00
00 00 9B 08 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 01 C0 BE B2 C5 85 BF CE 08 00 08 00 00
00 AD 09 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 01 10 6D F5 C5 85 BF CE 08 00 08 00 00 00
C9 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 01 20 76 FA C5 85 BF CE 08 00 08 00 00 00 3F
0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01 B0 CE 11 C6 85 BF CE 08 00 09 00 00 00 E3 0A
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
90 5B 2C C6 85 BF CE 08 00 0A 00 00 00 C9 09 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 20
76 FA C5 85 BF CE 08 00 0B 00 00 00 F6 08 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 01 E0 C9
D2 C5 85 BF CE 08 00 0C 00 00 00 F6 08 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 02 F0 2C C9
C5 85 BF CE 08 00 0E 00 00 00 91 09 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 01 C0 C7 EF C5
85 BF CE 08 00 0F 00 00 00 91 09 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 02 90 52 EF C5 85


SQL
SeniorPersonId | JuniorPersonId | SeniorPersonMisId | JuniorPersonMisId | LinkType | ParentalResponsibility | Priority | LastUpdated              Deleted
1              | 2775           | {null}            | {null}            | {null}   | 0                      | 1        | 2012-02-22 14:31:18.200 | {null}
2              | 3132           | {null}            | {null}            | {null}   | 0                      | {null}   | 2012-02-22 14:31:18.703 | {null}
3              | 3132           | {null}            | {null}            | {null}   | 0                      | {null}   | 2012-02-22 14:31:18.700 | {null}
4              | 2919           | {null}            | {null}            | {null}   | 0                      | 1        | 2012-02-22 14:31:18.423 | {null}


modified 24-Feb-12 7:54am.

AnswerRe: Reading Null values in a byte array Pin
Dave Kreskowiak24-Feb-12 4:07
mveDave Kreskowiak24-Feb-12 4:07 
AnswerRe: Reading Null values in a byte array Pin
Matt Meyer24-Feb-12 5:21
Matt Meyer24-Feb-12 5:21 
QuestionHow to filter record when combobox value is null Pin
polachan24-Feb-12 0:56
polachan24-Feb-12 0:56 
AnswerRe: How to filter record when combobox value is null Pin
Bernhard Hiller26-Feb-12 20:39
Bernhard Hiller26-Feb-12 20:39 
Questionaccessing the value of control between seperate Forms Pin
Fred 3424-Feb-12 0:10
Fred 3424-Feb-12 0:10 
AnswerRe: accessing the value of control between seperate Forms Pin
Smart Arab24-Feb-12 0:24
Smart Arab24-Feb-12 0:24 
GeneralRe: accessing the value of control between seperate Forms Pin
Fred 3424-Feb-12 0:36
Fred 3424-Feb-12 0:36 
AnswerRe: accessing the value of control between seperate Forms Pin
Richard MacCutchan24-Feb-12 1:26
mveRichard MacCutchan24-Feb-12 1:26 
GeneralRe: accessing the value of control between seperate Forms Pin
Fred 3424-Feb-12 1:44
Fred 3424-Feb-12 1:44 
GeneralRe: accessing the value of control between seperate Forms Pin
lukeer24-Feb-12 2:10
lukeer24-Feb-12 2:10 
GeneralRe: accessing the value of control between seperate Forms Pin
Fred 3424-Feb-12 4:40
Fred 3424-Feb-12 4:40 
GeneralRe: accessing the value of control between seperate Forms Pin
Richard MacCutchan24-Feb-12 2:44
mveRichard MacCutchan24-Feb-12 2:44 
AnswerRe: accessing the value of control between seperate Forms Pin
Dave Kreskowiak24-Feb-12 4:12
mveDave Kreskowiak24-Feb-12 4:12 
GeneralRe: accessing the value of control between seperate Forms Pin
Fred 3424-Feb-12 4:46
Fred 3424-Feb-12 4:46 
GeneralRe: accessing the value of control between seperate Forms Pin
Dave Kreskowiak24-Feb-12 9:03
mveDave Kreskowiak24-Feb-12 9:03 
AnswerRe: accessing the value of control between seperate Forms Pin
Shameel24-Feb-12 8:25
professionalShameel24-Feb-12 8:25 
Questionhow to filter chart by textbox & dropdown ??? Pin
Jeeten Parmar24-Feb-12 0:08
Jeeten Parmar24-Feb-12 0:08 

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.