Re: Odd Behavior Copying VarBinary Data by Eric
Eric
Tue Oct 25 23:55:07 CDT 2005
Ryan,
Unfortunately I don't currently have access to the DBs I need, so I
have to test this tommorow.
Thanks again for your help.
"W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
news:Oe7uJTc2FHA.2440@TK2MSFTNGP10.phx.gbl...
> Eric, if you would, change the code as indicated below and tell me what
> happens.
> "Eric" <dontwant@nospamfor.methanks> wrote in message
> news:ey1E6nb2FHA.2840@tk2msftngp13.phx.gbl...
>> Ryan,
>> Thanks for the response. I'm not even doing anything that complex.
>> Both DataTables are filled from their respective tables from different
>> databases. Then I'm just doing a loop copying one to another. Below is
>> the
>> exact code.
>>
>> if(drDest.Table.Columns.Contains(strColName))
>> {
>> bool bReadOnly = drDest.Table.Columns[strColName].ReadOnly;
>> if(!bReadOnly)
>
>> drDest[strColName] = drSource[strColName];
> Debug.Assert( drDest[strColName] = drSource[strColName]; //These
> should match - but if I understood you correctly they aren't, is that
> right? If so, tell me if the assertion failes.
>> }
>>
>> "W.G. Ryan - MVP" <WilliamRyan@nospam.gmail.com> wrote in message
>> news:e1lFRhb2FHA.636@TK2MSFTNGP10.phx.gbl...
>>> Comments below:
>>> "Eric" <dontwant@nospamfor.methanks> wrote in message
>>> news:eHL2SPb2FHA.3704@TK2MSFTNGP10.phx.gbl...
>>>> I'm copying the content from one DataTable to another. Both tables
>>>> have a SQL column of type VarBinary.
>>>>
>>>> The data is actually copied this way.
>>>>
>>>> DataRow[Column] = DataRow[Column];
>>>>
>>>> Would this method cause a problem with VarBinary data types?
>>>
>>> There could be a problem with the encoding but i'm not positive without
>>> looking at the code.
>>>
>>> In the following snippet, the assertion passes, is this essentially what
>>> you're doing?
>>>
>>> private void button7_Click(object sender, System.EventArgs e)
>>> {
>>> DataColumn dc = new DataColumn("Cuckoo", typeof(System.Byte[]));
>>> DataTable dt = new DataTable("EDC");
>>> dt.Columns.Add(dc);
>>> DataRow dro = dt.NewRow();
>>> dro[0] = "CuckoozRule".ToCharArray();
>>> dt.Rows.Add(dro);
>>> dro = dt.NewRow();
>>> dro[0] = dt.Rows[0][0];
>>> dt.Rows.Add(dro);
>>> Debug.Assert(dt.Rows[0][0] == dt.Rows[1][0], "Da rows don't match");
>>> }
>>>>
>>>> The problem I'm seeing is that the data seems to be duplicated.
>>>>
>>>> So, if the both rows contained the value "1 2 3" after the copy I'm
>>>> seeing a value of "1 1 2 2 3 3" in the row where the data was copied
>>>> to.
>>>>
>>>>
>>>> Any thoughts ideas are appreciated.
>>>>
>>>
>>>
>>
>>
>
>