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?

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.

Re: Odd Behavior Copying VarBinary Data by W

W
Tue Oct 25 18:03:37 CDT 2005

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.
>



Re: Odd Behavior Copying VarBinary Data by Eric

Eric
Tue Oct 25 18:15:19 CDT 2005

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];
}

"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.
>>
>
>



Re: Odd Behavior Copying VarBinary Data by W

W
Tue Oct 25 19:32:54 CDT 2005

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.
>>>
>>
>>
>
>



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.
>>>>
>>>
>>>
>>
>>
>
>



Re: Odd Behavior Copying VarBinary Data by Eric

Eric
Wed Oct 26 12:49:44 CDT 2005

Ryan,
My test using Debug.Assert did not reveal any differences in my
VarBinary Columns, however it did produce some strange results on int and
boolean columns.

Several of the rows with these column types failed the assert.
Debug.Assert(drDest[strColName] == drSource[strColName],strColName+" No
Match - Source: "+drSource[strColName].ToString()+" Dest:
"+drDest[strColName].ToString());

But based on my code above, the display showed the exact same values and
each column had the exact same datatype. Weird.


"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.
>>
>
>