Solved

Byte string to Byte[]

Posted on 2010-09-23
3
960 Views
Last Modified: 2012-05-10
Hello,

I'm trying to save a byte[] string, with the same format as you would see if you insert a BLOB into SQL. I get a string, like the one you can see below, from an XML file, its an export from a 3rd party that i need to import into our system. When i add the string to a sql query like this:

INSERT INTO dbo.Photo VALUES(<string you can find below>)

The picture renders on my website. But when i use the next lines of code the picture throws an invalid parameter exception. I think its a conversion to Byte[] that ruins the photo, but i'm not sure.

Any help would be greatly appriciated.
Thanks in advance,
MA

    string s = dtPhoto.Rows[i]["INP_Document"].ToString();
                            ASCIIEncoding  enc = new ASCIIEncoding();  
                            byte[] bArray = enc.GetBytes(s); 

                           

                            InspectionPhoto photo = new InspectionPhoto();
                            photo.ID = Guid.NewGuid();
                            photo.Document = bArray;
                            photo.InspectionReport_fk_INR = gInr;
                            photo.InspectionCriterium_fk_INC = gInc;
                            photo.ContainerReport_fk_COR = gCor;
                            photo.CreateBy_fk_USR = new Guid("90341D9D-7631-4BFC-AEAE-613AFCE6D855");
                            photo.CreateDate = DateTime.Now;
                            photo.ModifyBy_fk_USR = new Guid("90341D9D-7631-4BFC-AEAE-613AFCE6D855");
                            photo.ModifyDate = DateTime.Now;

                            using (ImageServiceClient imgProxy = new ImageServiceClient())
                            {
                                imgProxy.UploadSingleImage(photo);
                            }

Open in new window


this is one of the string (photo's):
0xFFD8FFE000104A46494600010100000100010000FFFE003E43524541544F523A2067642D6A7065672076312E3020287573696E6720494A47204A50454720763632292C2064656661756C74207175616C6974790AFFDB004300080606070605080707070909080A0C140D0C0B0B0C1912130F141D1A1F1E1D1A1C1C20242E2720222C231C1C2837292C30313434341F27393D38323C2E333432FFDB0043010909090C0B0C180D0D1832211C213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232FFC000110800BB00FA03012200021101031101FFC4001F0000010501010101010100000000000000000102030405060708090A0BFFC400B5100002010303020403050504040000017D01020300041105122131410613516107227114328191A1082342B1C11552D1F02433627282090A161718191A25262728292A3435363738393A434445464748494A535455565758595A636465666768696A737475767778797A838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F0100030101010101010101010000000000000102030405060708090A0BFFC400B51100020102040403040705040400010277000102031104052131061241510761711322328108144291A1B1C109233352F0156272D10A162434E125F11718191A262728292A35363738393A434445464748494A535455565758595A636465666768696A737475767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00D76650406201C640AA9697D6D7B3CD15BCAAED0901B6904735E79E24D7EE93C512BC126C302985533B81F5CE38E7D2B1A0D7AEB489279209764D3AED644E8B939FC0D69ED752153BA3D56FB5FD2F4BB9582EAE4090F5031F2F1DFD2B97D7B549359630DAEAB650DA7FCF3590867FF7B03F4AF3B924B8BD98C9339249CD5EBDB286CB4CB0999726E03B31039041C7F2A894E52358D351DCD81A25C13FBA9ADA4FF764C7F30291B45BF5FF009629F84C87FAD645BE96F756DF69863FDDF3FC783C538D85DC50A4C3CF546C60AC83BF4EF51691774683693A80FF0097399BFDC5DDFCAA23A7DF27DEB3B81F589BFC2AB9875589D53CEBC5660481E66738FC7DE98DA86A36EFB64D4258DC1C6D7EA28D434256564E194823B1148307EB531D6F5AB7D88FA88C328750C0720F43487C43A8FF00CB536B27B4B1E7F9D2D46458E697B54EBADCAC32DA6D83FBA46053BFB52D88FDEE88993DD2665FD28B858ADDA9F14D2DBC82485DA371D194E08A9FEDDA637DFD3AE63FFAE6F9FE749E7E8CDDEF63CFF7803FC85170B1D0E99E35B98711DF279E9FDF5E187F8D75DA7EAF65A9AE6D67566EE87861F85798EDD25BEEEA8CBECF6E47F5A92286DD5C3DBEAF68AC0E4166286B58D66B7329524F63D639A5AE2F4DD7F5280AC72CD6B7D18E0959806FCCE335D6DBDE5BDCA295954337F0161BBF2CD6D1AB1975319539449B14BB69DB6A8EAB2CD6B69F688586E43F75BA37D6A9CAC4A479FF0089A18D354947DA576B1C8801C95E3AE7B66B9A51BA4049DE7FBC0743F4AD1D5EED2F2F5A45B6681D986E8D0E54FB8C8E3E9544C250F9821704720F239ED5C337791D0B61C2212ECC3E438F9B00FC9E94F6C88C066DC0765E3FFD755D2673181B1723B13B79FCEA63211B7CC8F9200F97E9FF00D7ACDA19DEF82A74F29A001146CCE3712C4E4FE1DEBAFAF3BF07DEA5AEA890950C2518DE4648F403D39EB5E9014576509DE06125A8CC0A50B9E82A508BED4ED95AF30B948C447D29DE5E2A5C7146DA9E61D887652EDA9B028C0A3982C7CF5757E659A478CE19D8B34A7A924F6F4AA1B803F2F3CF53525C26D74C74C0350E3E5FA3573A47497EC4160D9E4E6B63C4685346D3010005795783EC959DA5C64DD1420E0B2F6AE9EF7489F5AD3218606456826763BC9008217DBDA9376655AE8CFD04A9D2082CE0EE61C038A7CAF9D2223E6B7010E38F51ED5774CD0B52B1B5316216F989EB9FEA2A49344D47EC3F66222DA001BB3E873EB4FDA47B92E9CAFB15E6653776DFE919E1867238E95CEF888017ED870C377DE1DFE55AEB9B4CD4E49E1711427CBCE0799D6B3358F0CEB1A8DD1992DE3C93C85947180077C7A52E78F7050976303571F3581F5B48FF00957404396B43F29C9E3FEF9351EA1E14D52E16CC2469BA2B758DC171C1C9AB6748D4BF70458A1119E793CF18F4F7A2338DB71CA126F639BD754ADD72003B8E71FEEAD77775A7BEA165A4BC5146FE5448C4B1C103E53C7E46B97D5740D4EEA4568ECF682DD3238E00FE86BBCD31B66996F0B82248A3547057041007AD67525B34694E3D1916B3A7C577A3DD456F045E7B2623217041F5CD43A2E876A9A45BC57B65135C28224623249C9EFF00956BAB2E0E78F734C49A37C9470403CE0FB561CCED636B2BDCA7278774771CD9275E76B11FD6AB3F8474873FEA5D47B356C6EDA3248C7BD2238750D1B020E79068E69770B239E93C11A537496653EE41FE95D4685A1D8E97611243046655CE6528379E73C9AAA580EBC1AE335CF11DF457125AC372E9E45C2B80BD3685F5FAF6ADE8CDA7A9856869A1EAB8AC6F146A49A5E8D2336EDF2831C640C80D8E335C95A78DEE2E6F74A49885227C4C5460107E51C7E66B53E20DCC03495513E27CFCA9C1C8EE71F81E47FF005ABA1CEEB439942CF53CF9A70F7AC1D0303F78A7CBD49FCAAB9967DD84DC075604E78EDFA531642B3EF2C0823A77F7A7CCE779C3B8C80495AC0D2C4BE64A386018F6CFDEA19E457DB279424C65BB9C63AD2C2CDE7465648C9C636B8CE3DCD59BAB748E3491E5C5C38394DA08D9EC7D73536420D26E9ADAF43AC8C0F51E5F519F4AF68B11BAC6026364CA0F95CE5871DFDEBC42D04AD2971BBCAEC0F071FD6BD9F4B92E1B4DB7698A876404AED3C7B75ABA575264C91A20014B915893EB325BEAA6D645856048848F333118E718031FD6A36F1569A3205CEEFA42D5B7320E46741914135CEA78AF4C79D6333CC9BBA332714E8F577B9D6A3B5B59E292D4C5BCC8BF31273D3238A399072B37E9B9A8B9CFDF6FA714DD8BFDE7FF00BE8D3B9363C1FEC4F75B18062303902AEC1A330E4AA8E7249E6A4B5BB921D1ED5D11586D3B893D00603FAD2BDFDC986360554B48C8D85F4E9585D9D3645DB6B14B770F9248E9C56FE8F20549959B1F30239EBC1AE5AC2598EA1B6599E457B75930C7804E0FF5A975DCFF0063B95278990E7F06A9B5F41DECAE773BA30705D7D46E6141756EB245C0C0F98578E382D6E5C9390E07AF507FC2A3C0F314E4F6ED47B1F31FB5F23D999CB40C1264048C02ADC8A7C72C8B1A832231039C1AF21B0655D42DFBE251907A75AD7D56D24896710C72AFEF11BE4C91C86E9ED52E959DAE3553AD8F49493962719EBD45384A07CBBC0F4AF2BBA86E8E9D627CB9F3B1C1C21CFDE3D7F3AECED3C3F05C69BA63FF00650597E469DDE52372E39C8ED9349D34BA89D6B6E6CCEE77DBB16E04BCF3FECB0FEA2A619F35989182A0649FAD5583C29A6BDE2CAD6CF1C41B704595801FAFB56B5DE85A65F2C6B35B17588E533230C7E44566EC8C9E3229EC665ECDE55AFCCD8DC40040F7AB8B0DBACE1AE2FEDEDCB443FD76E07D71D3AE083F8D58BBD22C2F94477306F51D8BB0FEB51CBE1FD2EE65125C5B89881802476C7E8451171EA4BC645BD08B6A4775E5DEDCC56685B746D2B8CC8983F3019E9C0FCEB5349D0DB5733B69D7314C9BB7798410A7800FAF348DA768B717314B7DA4432B448B1A3A4B282AABD0637D759A2CBA658ABFF6747146243B9D5647249C01CE4FB0ABF71971ADCDAA673D2F82F5AE40FB2118E3129E7F302B88D5BE1978AA5D467996C9648646078B98C13C7A1615EE69A96EC65957F33FD6A66983A6EFB40EA3A6077F714D24B61B9B7B9F384FF0FBC456CBB974AB82E8D90530D9FC89AA9E27B5D602C2FA8E8D7D198801E7C96CEA00F424F15F4E9923FF009F91FF007D2FF85723F10AF65D3BC366E74DBA314E25504C6C092BDC62AE2C9B9F342BA47204DBCA9E0E71526F56DDC92A33D0E31C56BEA96AF3A2DEC70A8DE764AAA8546EE70DC0EF83F883EA2B29E19F850B211FEE907F955302D69D01BCBC8E18D11486CB1EE14753FA7EB4EBAB9B896F249922DB0A9DA09E32A3A7D38A9ED8CB168579341148D3C8C22CA1DC517A93ED9C63F0AAD616F3C51334DE6E1382832727B7F9F6A968410CA12E4905B72F3863C62BA9FF0084B2EE5B716914CB0E0001A31CE3D89CD73F25B8668E407CD232BCAE0FE357344D3A5D57548A185511B383E610A081EF53CD6D506972CADC4891C80C924864187795CB31E73D4FD05444E7D47BE6BABD43C2F269D7F6D62D25BC92CE463683F2E4E06722A0F117842E342D35EEEE5E0653955F29DB20ED27D07A53B9BDD6C8E6186E5C1CFE1DAAED85F4B0EE319092F42C383EB915CAC3752492152F27DD63CB91D01AABF699F7773CF218E7FAD572B279D1E8CDE20D536822E828039CA291FCAA89F16EA4091F6F4E3FE99AFF0085714D7D305EBC0E829BF6C9CF2193FEF914D297725F2F6376D74CBA9AC5ED6DE269D62043C918242966E07BF38AB775E1CD46D2D7CEB884C6826F342BAED600923BF6A82C75CB9D2378B537210B865121500608233C60F20549AA78D357D59BFD2A68DC63690645191E9C62A9AD48BC89F4BD12F2E67B799444A16DC2B2B38DDC018E052788EC25B4D31A36113BBB2F0B202CB8F6EB588FAD4AC815A58768E8A771C52DC1BD5B55B936DE5DB9C1DE304E0E79C7E069283BDEE5B9696B14ECEC9EE219A0219092A726366C73D78FC6A43A1CBF6732E5FCD53858BECEF96F7CE31FFEAAE8BC217F16EB84906F4001F31A30307D3AFF009C5752753B70A7F798F418183FAD44AA38BB0D4535B9E676DA56A09771B35A4A02BE4E531819AEDE1D0CDD4AE89BA288601908F427A7AD6C5ADD4572C6346C81D7815A0ACA30A3000A9751B31AD514348EE36C34EB7B288244A72060BB1CB1FC6AEE00A8C3803AD01F3DEB36CE26DBDC9831AB51A7CA3DEA921CB015A6A985158549194D952EE16311923FBEA338F5150417519B579E4202A0C927A0F535A7EF5CDEBD6F243E1DD4A3833BB0C576F5C707F954C5DF4263ABB18E9F112C1F50101824584BED12E3F5C7A5755BCB0DC0823A822BC4E3B73876723663E5239AF5DD2A099342B14772B22C49BB8CF4038FCAB6AF4D46D63A7114942CD1E97A39DDA6DB860A7F763A8E4D70FE33F8989E1DD61F4AB5D361BB68C0F39A4600723EEE31D6BB3D0E3792CACE61230558D94A6386E7AFE18FD6BC3BE25E9335A78EEF2790308A7712C64E70C368C8CFB106B5A76695CEDA7F0AF43D6B40B0F0EF8B7468B57B5D3228CCB9DF11E36B0E0AF1C0FF000AC6D6745D22E6EFFB26DED9ECEE167547976920064660473CF4AD4F849A75C69DE1226E226885CDC34D1AB75DA4281FFA0D759AB69A2F561995B64F6EFE6210339F948C1FCEAB6655D9E2DADF81752D35E016AED791C876B3862841C8E305B8FA835CF6A1A65D69D7AF69751CB14A9904090E0F7E39E87B57AAEB1E29B3D2ACD676B88EE5B7ED48E0018E475FE2EDEFD735C7EA5E205F125C2CF6F1342224D84B01F30E48F5A7776047130068AF42A19510920AEE2013B73EBFE4D6A794AD6ECDBE70430C1F31B2073EFD69D046EDAB4A7E6DE253CE7FD81C56AEC9096F9C93C1EBF5A1B1D8C5087230F364F40247C67D2A58A09E5B854135CAA363277B703D7AD6B08A51FC6DFF007D50558F064FD6A6EC562CB5BD8FF68AF973DD9B45750D999C1E83777EF4FD620B1781174C9AF838CE4C93B1078F7359E3CB50C1A451F390327D8714C9A5B642312AE000587538C75A7A8CCBBC8F50B3B7795AE66200E3E61CFB5638D56F8E36DC393D4671CFB7D6B4B5ABD827B2912191BE4C33100F4C8E47E75CE8625B6E029E33CFDDCE30D5A475DC4CBE355BEDC009DB279425471EA0FBFF009EF4C3ACDC64E2593FEFD0AA6CC15987240E1C71F838FF003FCE919A52C4E51B9FBDB179F7A76108BA2EA4DD2C87E320FF001A7AF87F5263FEA635FA9CFF004AF51CDD6782ABDF8514AAB739FF005CFF0081ACF9E65591E66BE1ABF3FEB258107B29CFF2AE9156FE5D1869F232E30ABE62824E07A67FFAE38E9DEBA930CCDF7A6909FF0078D38583C9FDF6FAD27293EA3B2392834F9A24D81E4908E99503F954E2C663D531F5205754BA4C9DA33F8D3FFB29946582A8F56359B8AEAC7639981E5B10DF28E79E0E6B56D5A6B98E37578C338C846273D48F4F6A8AF6384CB88DD645DBD57A568E9E618ECA066DBBE30CC323240C9E957148E49454A6EE45FE968DB4C6ADDBE5914FE99A47BEF21824CAC8C46406AD69375C444C6A5D0A1208720EE1D39AE7757B4F2A1B2C2B2FC872ADD4739FEB44A2853A5151B9B365729338C106B7D9C6C5391D2B8AD1722461F4AE99A429106E781DAB92A2B338A6ACCB9E62FAD579C893A63DEA30DC77AB3648183F2776477A84AFA0E9C39E5CA7271F86B414D43CCD89E66E0FE5973B73F4FE95D1C852281A47C841804E3D6A39D63FB618F6A92492013C9E6A496559B4DBC802E022E719AD1ABEECEC7864FE26D9ADA278C34DB6B1585A3B8678B3CAC7D89CF722ACCDE2FD32E56590DA79C22214A4806E56C81D003EA2BCEF54B8B9B2D39A7B38B3300BFC39E33C9C557B1B7D45DAF64B7B169A49A40D128C95C91C9E39C0FE95A2BDB43B2108A8A47A8D9F8B8DD5CDB4496AB1895C273264F5C7A5751BD88EB5E71A168BAA422CC9D34C45195980380A41CF56C1AF47C73570BF514D2E87CFDAB4D1C7E23D42DE4B35581259630AA09E771F9B9EE71FA556B226D212A9939393DAB6BC4D06CF126A2001933B1FCCE6B15BCCCE0283F8F5A1D46F4158AF6D330B99A419DCD23F7FA55F1704ABE58EEC8FC7AD65DA920B9031977E33EE3A7F4ABC4B6DE791DC0A272698243FCC623EF31A6966653B7AFA668DD9C0C7D08E9F5A6B2384C85247A0F4FF001151763B099DC8BC061D727F9FD69648959882880F4C807AFAE2A98BDF2646F35E300F6DC383D8E3DE83A81775DA9239C1E141C7B83DB3DEB4519315922736919E04680118E074F6AAF369B6EDFBC03E64048CE7F234D96FE650716AC463F8980247AFD45539752BA662A61011B86232770FEF0A71A7316839749B62CA91CAEC1F24120F38FE1CF71CD34E85699FF8F865F6E38AAB2EA177B0F992302BC314E38F518FC2905DDFE0621561FDE2E79F7EB5AF24FB8687B2ADAC2BD431A7AC502FFCB21F8D2939F5A692074AE7BB3649126517A220FC298D3E3A1C7D0533713D45433CBE5C6CC10B9033B54649A43D06DCEA51DB83E64BCFA0EB5CEDEEB12B9C47F718F1B87FF5CD43A9DC4F3485CC462DE71B4B007F9D6685642486638EAA79349899760DC51988C12C49F7ADBB5B5FB469AAA59D0B23A0923EAB927922B12D8B793961CE7D2B6B4ED42DE084453B3019C838C81FE7E95B43638EE94D9A761642D2CE18BED2D2344BB7CCE99E73593AD105E35F356460CE4E1B3805B23F4ADA06DAE706378E4E3A1C1FD2B23C40C01B60A000148E060537B0EA7C255D246D99FDF15D29FBABF4AE6B4B3FBCAE9B1C2FD2B92AEE79F537102D4B1CDE4A901739EF5106CAE7DE909C8AC936898CA50778913C31B5C79E41DF5B767A2492DBC729915629B924293DF1C9AC9EAA7D6BA8D0596E2C5235E6E208C861F7739627EF03F4ED5AD3D5EA7451939CAD264D61A5D869AF9768E666E77795CAE3D3AD5F32093710E18678E3A0F4A89ACE4FB423B32601F424F3EE3156658BCA8C60939E79C56F6B23BD249591650F029D9A645CAA9F5152115423C57C6A863F16DF807AB29C7D541AE70B155625CE7D45755F10230BE2D9C9E8C88DF5F971FD2B937DCDF73BF24E4564F735E847691A2ED5662A5D4B82BCE727357E2921527746CD838C6EFF00EB537C3FA6C5A94716CBB8A27202E58FDF3D828EB562F6D45A5DCB6E640FE59DA580EBEBF91AB968EE4C5904F32B1FDD468A1B8C73FCEAB3451960ED1249820FCF96C7A1EB56B6A8C820F1D8535923209CED27B91DCFF4342A96E8368AF8B50367D8221DBE462BF87434D78ACCF3E5C8BC672369FC7B55931A03F23B00476FF3DAA168083DBEA7D7FF00AF5A2ADA936D0AB2DB44C7E49CA9EA03640CFE191835972BC88FB04720E7009E9BBBAFD2B74C240DDB548F43FA8A638C8E1415E3A01C8F5AB5550B94E5DAEA46FBAC15BF878CEDF55A8BCD43FC328FF809FF001AE9A5B78E4CF99186F5CAE7F1A84D842C726DE262792C475F7AB5342B1EAC719E29A40CFBFBD3C8A4C7E55C86C4670A72C401EB55A7BA8D4616558CFA91BB3FAD5CDB9078EB55DED63727700C71D302930B9CE5E456933379503BCBD4B9F5FF003EB5516CE5C21C10CDF755B835D6F90D180B0C68003DD8E31F95417B7367650F9972C235CE320753F852B5C6739E5C90864954870738229AA3231EF534D7505EC8D3C04F94DC2EE183C715006DBF4AD169A1C13F8992B2FCBC70474A6C92C92ED12C8CE1785DC738A72480F0691864D320B5A61FDF115D30FBA2B97D346DB935D383F28AE6ABF11CF577131B4607A93499A7119A61C0EBC0AC4C8515D0F8508FB74E9EB0E7F223FC6B9CDDC6E1C8F6ADAF08B91AA80DC6E4718F4EFF00D2B4A6FDE46B45DA68EC270328474C517001B753DEA8C7AADADCAC8E932EC8E4642E46D0769C1EBD7078CF4AB02F2DEF2D49B7952408C0315391C8047E8457635B9EA268B10FFAB5FA54951407E4152138A480F21F89C8CBE288981E1EDD73E9F79BFC2BCFAF6E65873B515971C915E81F16FCF1E20D385BC52C92496E4011216270DE83EB5E593DD4B0196372C2473868CAFE873DE850BBB8DBD0D1D235092D8A34523F077AA9F9829F606B645C4972C667625A424927D735CB59CCB05D1CC478201E38F7AE916E2321807C1E98353516A1026C907693EFD7FCF4A0C801395C8E98E3F2A4C8932178618C13FE7F0A78D9B09390C3A0FF003E86B32C633B923AE73C1C77ED4D0D9CA939073F2FA7B7D694336E2BB49383C67F4A6B0030588C75C8183EC68018D8E818E09C923F434170013D0E78E3807FFAF4302407006071823F31FE1484A3E085DC00E98EA3FF00AD4C41BC9C6D1C1FBA08E9EA0D1B223C991813DBD2A360B9F986411CF3D7D0D05C8620C793EBB7AD160B1E9C727A0A8C9208C8057E95367041C77EF4C6396CF1F9550C1997A6ECFD2ABFDA620ED80A1871CF19A919300E7A1E4D675D413C8773B218B19195008A4D8CB8D270780D9EC0E6B99F14C77375A63BF938585830E7B74AD27BE7B6601D7E51ED9E3EB4CB8BB8AFAD248B20232957DC47191D69C5D9DC4F6399D3770D2E227AE4FF00335677122AF5A69B6F259A7D8242401931B9F9BDF1EB55A7B76407820F4E3A8AA6EECE26AEC58065777AD3DC9C8A64520006EE9ED52360362842716B72D580CDC7E15D2AFDC15CD581FF0049FC2BA5420A0AE7ABB9CD5771BB7E7C8E33D7DE9FB45373CD296158988846722B47C3EE22D6ADC8E012C0FE208ACCDDCF42734DDE2A93B3B95176699D04DA6E9D6F7B6D0A6A1F2A0D890A0DCDC307E4FD56B6EC2D6DAD6D1D6DA32AAD8C92D92719C5709692793AD5AE3B924F7EC6BB2B4B942A46E00F4AE98D594B73D2A16946E91AAAD8C63D39A941CD57678D14B16519F538A7ADCA30F951B8E32C368FD6AEE6B632BC4D770E9F6525D3C51B3AC6487660BD39C67AF271D2BC0BC51AE4DAE5CDB49711C11C36D1228584100B9C166E79E7D3DABD9FE204705D7866E04A15DC15D8B9E8770FD719AF22D43C3EB25A322DE3C607CE0320C6EF41CD38B771BDAC72B25CCBB014DCABB761663D79CD5AB19190ECBA946C6C36E1F38048E075E3DFAD4E3C3F78F246229522C0C33B123F1E2A53A55C69D2B25D0596507736F424E7A8CE4035A3942C2B345B8197ED45249E330458DD287F94F19C67F100FD2AEADB4F269B25E45346F0A48131DC9FAFA62B9D46F25DC3C421CB6762938C63B56BA5D4E7479D63F9E0DEBBB7E383CE00F5E33DAB192D741A624574FB8E7D31F2FA7F88FE552F9CAFF2EE0ADCF046707D2B322954B6E624A839233D7DA95E555248042FF7739A1C50291A3E7854CB0629EBEA3E9EA2AC9281470BC77F7F5FC6B0BED45B2BC126A44B8747568DBE51DBDBD28E51F31B0541388C1EBD3DFD2A1FB347E8A3EAB9AAA97ACA18B65FFDAEF8EC69E6E98924DBA13EB83CFEB4B958EE7AAD042F3BBA77A4634991904F3486395D4A9C631DB155A78D668B612C0FB1E4D3DA4C0C28A85DC81BB8028B0EE654DA74A23C245B8118181D2B9FB9B1BFFB5148A3675EE0F5C57682770B90C08F5A72DC90012A083C64524AC0F53CEA0BEBAD12568AED58C2AD95993AA8F461D7F1AE9A0D42DF508879DB5830F9654EBFFD7AD2D474F5BE84AC71AB1CE7A8AE4AE7C3F7BA323DD5ACF1A81CB4273B58FF0043EF5574F7309D3EA8D6BAD2D9177A1F323ECE9D47D6A19172322A9697E212DEA92062AF19E40FAD6FFF00A25F2768643E9F74D1AAD198C969629E984B5DE0F5C575283F762B9CB4B59ADF505620346C0E1D4E457490B864C007838E95954D59CD562EE31BAD34E4D4ACA3BB014C3E58EA4B563CACCF9189F756A83DE46090A0BB73F2AF3524FA92C64A2463EEE793D6B9D87575DD22B32B3B1FB910DC47E5D2B5853BEE7452A0A5B9AF15CCE97915CF97B761E037D31FD6AC4FA8CF26D73725157E6051B1596B3DC5C8C322C2800219C8273EE3FF00AF491D8C929FF4A679C7A6005FCBBD6EA315B1DD08722B23A7D3BC4F6D15AF9B2C725D5D2B603A217241E8371E077EA4525D789F56D4001651C36F19382CEC4BE3DB8C7F3AE7D34E98968630D0291C11C1C7A7AD5D86C1AD640639E6D80708DF3007EB4685A1D7F6B726DFCC96E1AEAF80CABCF29F2C37B01C0E3D00AC65D2649A30B2CAA66604E15F80D9F53DB1EB5D03C724CB87F987BD4525BB13C8079CF228DC665B69F2AC8584415303E4460C47F8D5396C2095FCCB843C9E5875FCAB75A020FCA39F53558DD389992443E4AA93E737CC991DB8C9A9E51DCE56EF4552C5A11E606E02938FD6B35B4BB9891C089B000CE7FCF35DCB5BDBDE4713441A2DC01CF41D38E3152A68B68DA4CEB2AC8F7ACE3CB653808A07EB934D5F625A89E61E5CD1DC952A7DC7E35AB693450C72B346923E30031E9EF5AD259DC4624F321661BB0415EA47A71EF516A11DB5C5CA62D1AD88500F94A70B8EA4E7A50DB7BA17235A9802DE4677638273FC23A8F5A93ECB29C840E5BAE3AD5DB648616F9A4E7D0F7153389616662A367209C76C7F850E6C5CBDCA090BA0C11F29FBBFD69D893FB8DFF7CD580AA0818C8719C16E86A631440FDE7FFBEAA5B1B47A63824657155D9991F07241A955F63ED34B213D718156037689633E5B14354D6CA76C9931BBFBC4E6ACEE23BF34A5DBD4D2B0D318232ABF336EF6038A8594039EA3B8CD48DE6004AE0F3D3BD0C87A8EA28B582F722F30C6D94C11D4E3AD399CDDA346CBB548E4F6A6B21231FD314DC027B8FA1C668B01C96A9E1998CECF02A283C175056B15AE359D06411DC2FDAA0C71FDE0057A6ACC0E030E7A727354751D12CF53019DA40C060146C5352E8C994534731A2F8C2D4C86392631027857E82BB0B5D5ECE5859D6E63DA792C5862B969FC216913063099075E4E0FEA2AED95869F0F10D95BABAF525064529422F5464E82342E75889E50B68B25D11FC510DCBFF7D74FD6AB6CD5E7DCF2CB05B46795C65DBFA0FE757816DBED8C7CBC714F8E3053DA928A45AA514630D32295C79EF34A475329047E5D2B452C624FBA1071D02E2AE34208C0E0F634C00C6E3703B7A64F6A668B42186D178DAA30BC7AD5C8A350C3B81EDD6AC44415207033F9D3C63A0ED400F47553FE06949E72306A36E9D29474C91400846DC8F9B07BE69A307201048F4A19B03BD44094C95EF400FDA7AB7E94C796350475FC29A5B2A5B2060D40F9C67008F6A6031CA963C003EB4BB8043B65D8DDB148A3E6E7A54726DC707EBC5302B4D717206DB9F29E36079C6491E9D78A6422DAEA479021575E18939C83F5F5A924856E14236E207A76A72B4609106D214ECE3B1AA76685A99D7BA4DAC8A7CB54494302A464607E3C1ACC36573BF61460E41F97B63F976AE8018951808C6FE482493F87355E5D4E3F28A7DD98FCBB48E2A1A434DDCE6CA072CB965C37CACBDFD6A5C9C747FF00BE4D3D0BA124156EA463903DB150991893891B1EDD2B3DCABA3D18863907A8A746D91E593F4A09CE47F10A438C6E1C9EF5A1029523A8A6F4C8C76EF4E2C645EBD3B5271D3D3A5002639CFEB4D209604923D853C1EC734A460673D7D28023233E99351B803927F3AA573793C52846511A1EFD6AD5AA210643976E9F373FAD26CAB0BE59C12C78F6A8DA3653C743DF38CD5D78D101C1C679CFBD421769DC467F950224B72AFF002BB37038C543716305C16014C720E9228C548B8ED9F97B62A643E62FCE3A7BD26063451DC2315940751D593FA8AD084AB282B8DBDA96758D57E5C2E0823EB59925E451DC0611BAB0CEF00121BDCD1719B1C115118C0DC5573B8FCC33D6ABDBDEA4CB81B87A1037035736E08EA28B888A2CE30A4900F03D3DAA657207CC7E94B819E075EF40F973924FD6980E1D07343390319A85A41D40A6993D47E7400F2E3A814D033F366A079C02029EA7141661C76A604CF183827B544CA782BC5234DEBD31481C7AE01A0047000E4D42655208E3DF1DEA49304F1CD4423EA4629A0133CF0326A27894F2C791FC678239F5A74B20801DC4EEC642773ED58F26A125D7EEA54F2C6EE8A783EE0D26EC0913CD3F972158DF91C6E6C563DCC8A19B73E1C9C2918EBEDF8FF3A96708A721B7ED350FCD22B9400B60968DC118F4C7F8D45DBDC3D072C280A032741820F5E4E79A88C232798FF3A74CC4B2C5E5AFAE3FAFF9F5A88CE99E4007B8E78FD280BA47A64A0821C751D69BF74823906A56E9508FB8C3B0AB448636B71D3B54814100814CEB093E86889886EBDA818FDB83CF3ED40E9EDDE9D2F040A45EA3DC734808668A39A328E0329ED51AC4B1A6D56240FCEAC7A8ED51B0E290EE35BA7279F7A4FF007B8F6A749C3628FE014C06E09E1463DEAC47F2C7C9191E951C6332107A5487EE13DE930451BA8CCDBD4CA006002AFBD316D9D516378032E3EF06A58517E47C7CD93CD5C427046780690CA56D0456D34816108A4E7827935704A0F56F94556B82411838ACA91D85B3B062093DA803A1247514C21C0E79CFAD616993CAD3B2B48CC33D09CD6E824834EE219B70A013ED48546DF5FAD04FEF48ED8A47E334C084C0AAFBF19347033CE7DA9CCC430C535BA834C08D87A1E69369E0E7F0A76339A6FF00101DA98861043E067DEA85C6A69680BB452310780BCE7DF35A8115A06DC01CE41CD655C46929995D41010E3F0A4D8D1467D5EDAF11A42F89473F41D3007E06A89BBF30EF525954F61DBB7F51C5558E18FED07E519F979EFD4D530ED1DBE50E0925B23D6A5449736CD6788C887E600BF500671EBC1A8E292EF69B5F390C59073B79C807A1EA3BF7A6ACAEF8DCD9DA06323A74A8E7765248620EE3FA50BB032C04669C2CC76C878046083F5A6B33862191339E79AACD34807DF3FE454AB7538503CD6E94EC3E63FFD9
0
Comment
Question by:MobileAccess
3 Comments
 
LVL 28

Accepted Solution

by:
strickdd earned 167 total points
ID: 33744693
I believe part of the issue is that when a photo is stored in XML it is Base64Encoded. You will need to do a Base64Decode and then convert it to a byte array. I don't think that would cause the invalid parameter error. I would say, start with the first parameter and enter a valid value manually, test, if no error then repeat with the next parameter.
0
 
LVL 11

Assisted Solution

by:William
William earned 167 total points
ID: 33744818
What version of SQL are using? MSDE? 2000? SQL EXPRESS 2005 or 2005 ? or 2008
If you are using 2005 or above SQL has an Image data type that you can use for the backend. for your front end you convert the image to a byte array for insertion:

ImageConverter converter = new ImageConverter();
SqlParameter imageparam = new SqlParameter( "@Image" , converter.ConvertTo( image , typeof( byte[ ] ) ) );
Hope this helps
 
0
 
LVL 16

Assisted Solution

by:kris_per
kris_per earned 166 total points
ID: 33745679
Instead of converting the string to bytes using ASCIIEncoding, use Convert.FromBase64String method and then pass the byte arrary to photo.Document.
string s = dtPhoto.Rows[i]["INP_Document"].ToString();

            byte[] bArray = Convert.FromBase64String(s);

            InspectionPhoto photo = new InspectionPhoto();
            photo.ID = Guid.NewGuid();
            photo.Document = bArray;
            ...

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error on Add method 1 50
Syntax Error 2 62
how to convert MM/dd/YYYY hh:mm:ss AM to YYYY-MM-dd datetime format by linq? 4 48
C# Desktop Application 3 29
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question