copy / insert a binary field to a SQL Server Databaseusing "AddInParameter" in c# with Enterprise Library

  While sync'ing a remote sql table to a local sql table, I have some stored procedures to select the data with a reader, then insert the data into the second local sql server database., everything was going great until I happened upon a table with binary data in it.

I'm using Microsoft Enterprise Library.

DbType.String, DbType.DateTime and DbType.Int32 fields work great
Just not sure how to do binary.  Any examples would be a great help!!!

Here is a code sample:
Debug.WriteLine("Downloading Sec_Permissions");
            remoteCmd = m_remoteDb.GetStoredProcCommand("eVent_Sync_GetPermissionsDetail");
            m_remoteDb.AddInParameter(remoteCmd, "LastUpdated", DbType.DateTime, "01/01/1980"); //ToDo: Put in LastSync'd date here;
            using (IDataReader reader = m_remoteDb.ExecuteReader(remoteCmd))
                while (reader.Read()) //ToDo: put in DbNull Checks for columns 1-3 as well.
                {   //GetString index is order of eVent_Sync_GetPermissionsDetail stored Procedure - 0 based...
                    DbCommand LocalInsUpdCmd = m_localDb.GetStoredProcCommand("eVent_Sec_AddUpdatePermission");
                    m_localDb.AddInParameter(LocalInsUpdCmd, "Permission", DbType.String, reader.GetString(0));
                    m_localDb.AddInParameter(LocalInsUpdCmd, "StringID", DbType.Int32, reader.GetInt32(1));
                    m_localDb.AddInParameter(LocalInsUpdCmd, "Description", DbType.String, reader.GetString(2));
                    //m_localDb.AddInParameter(LocalInsUpdCmd, "MAC", DbType.Binary, (reader[3]== DBNull.Value ? 0x00 : reader.GetBytes(3,0,)));
                    m_localDb.AddInParameter(LocalInsUpdCmd, "MAC", DbType.Binary, null); 
                    m_localDb.AddInParameter(LocalInsUpdCmd, "LastUpdated",DbType.DateTime, (reader[4] == DBNull.Value ? Convert.ToDateTime("01/01/1980") :  reader.GetDateTime(4)));
                    // reader[m_stationPrefs.JournalFieldSearchType] == DBNull.Value ? "" : (String)reader[m_stationPrefs.JournalFieldSearchType]

                    Debug.WriteLine(DLog.Log("eVent_Sec_AddUpdatePermission"), "Sync.Download_Sec_Permissions");

                    int numRecords = m_localDb.ExecuteNonQuery(LocalInsUpdCmd);
                    if (numRecords != 1)
                        throw new System.Data.DataException(numRecords.ToString() + " records inserted-Updated into evnt_Sec_Permissions Table: /n");
                    iInserted = iInserted + numRecords;
                    if ((iInserted % 2) == 0) //only bump counter every other record.
                        sa = new SyncArgs("PermissionRecord", iInserted);
                        //Raise the OnBumpCounter event.
                        OnBumpCounter(this, sa);
                } // while
            } //using IDataReader

            sa = new SyncArgs("PermissionRecord", iInserted);
            OnBumpCounter(this, sa);

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Todd GerbertIT ConsultantCommented:
Have a look here, let me know if it helps or not. 

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
carl-Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.