none
how to store image from datatable to another datatable RRS feed

  • Question

  • Problem

    How to store Image from datatble to another datatable ?

    I have table Members have field MemberImage datatype on sql server 2014 is varbinary(max)

    I have datatable dtDisplayDataPayment this datatable have data from sql query as

    select MemberCode,SpecialCode,Name,MemberImage from members 

    i retrieve all data and put in another datatable except image

    How to get or store image on another datatable ?

    you can see here on code symbole ???  to know what i need

    string sql= select MemberCode,SpecialCode,Name,MemberImage from members 

    DataTable dtDisplayDataPayment= DataAccess.ExecuteDataTable(sql);

    public DataTable GetChecked() { DataTable table = new DataTable(); table.Columns.Add("MemberCode", typeof(string)); table.Columns.Add("SpecialCode", typeof(string)); table.Columns.Add("Name", typeof(string)); table.Columns.Add("MemberImage", typeof(???????)); for (int i = 0; i < dtDisplayDataPayment.Rows.Count; i++) { bool Ischecked = Convert.ToBoolean(GridFooter.Rows[i].Cells["PrintFlag"].Value); if (Ischecked == true) { DataRow newRow = table.NewRow(); newRow["MemberCode"] = Utilities.ObjectConverter.ConvertToString(dtDisplayDataPayment.Rows[i]["MemberCode"]); newRow["SpecialCode"] = Utilities.ObjectConverter.ConvertToString(dtDisplayDataPayment.Rows[i]["SpecialCode"]); newRow["Name"] = Utilities.ObjectConverter.ConvertToString(dtDisplayDataPayment.Rows[i]["Name"]); newRow["MemberImage"] = here what i convert ?????????(dtDisplayDataPayment.Rows[i]["MemberImage"]); table.Rows.Add(newRow); } } return table; }


    Thursday, January 31, 2019 2:57 AM

Answers

  • binary not defined on csharp

    http://net-informations.com/q/faq/imgtobyte.html

    http://developerzguide.blogspot.com/2016/02/storing-byte-array-as-column-value-in.html


    Thursday, January 31, 2019 8:04 AM

All replies

  •  table.Columns.Add("MemberImage", typeof(binary));

    Thursday, January 31, 2019 5:23 AM
  • It seems that you already have the DataAccess.ExecuteDataTable function that creates the datatable. Then check the value of dtDisplayDataPayment.Columns[“MemberImage”].DataType. Probably it is ‘byte[]’ and you can write ‘newRow["MemberImage"] = dtDisplayDataPayment.Rows[i]["MemberImage"]’.

    See also: DataTable.Copy.

    • Edited by Viorel_MVP Thursday, January 31, 2019 5:51 AM
    Thursday, January 31, 2019 5:48 AM
  • binary not defined on csharp
    Thursday, January 31, 2019 7:47 AM
  • what i write 

    on 

    table.Columns.Add("MemberImage", typeof(???????));

    and

    newRow["MemberImage"] =?????????????????

    Thursday, January 31, 2019 8:02 AM
  • binary not defined on csharp

    http://net-informations.com/q/faq/imgtobyte.html

    http://developerzguide.blogspot.com/2016/02/storing-byte-array-as-column-value-in.html


    Thursday, January 31, 2019 8:04 AM