Author Topic: Type of Value Mismatches  (Read 2138 times)

Offline rahulpatel

  • Hero Member
  • *****
  • Posts: 139
  • Karma: +1/-45
  • Gender: Male
    • View Profile
Type of Value Mismatches
« on: December 13, 2012, 04:44:08 AM »
Hi guys,

trying to pull in some data via a query and then display this on a form. I've coded this in c# but i get the following error.

"Type of value has a mismatch with column typeCouldn't store <System.Byte[]> in Company_Id Column.  Expected type is Byte[]. ---> System.ArgumentException: Type of value has a mismatch with column type"

does anyone know how to fix this?

Kindest Regards

Rahul Patel

Offline Saurav Jaiswal

  • Hero Member
  • *****
  • Posts: 115
  • Karma: +30/-0
  • Gender: Male
    • View Profile
Re: Type of Value Mismatches
« Reply #1 on: December 13, 2012, 07:26:18 AM »
I guess you are trying to associate a field of type ID.
When assigning values to a variable of type ID, if you are not directly assigning from a datatable, make sure you convert it to bytearray.
e.g. Id xyz = <saome variable>.toByteArray();

Hope this helps.

Regards
Saurav

Regards
Saurav
Infosys Limited

Offline rahulpatel

  • Hero Member
  • *****
  • Posts: 139
  • Karma: +1/-45
  • Gender: Male
    • View Profile
Re: Type of Value Mismatches
« Reply #2 on: December 13, 2012, 08:26:19 AM »
thanks for the reply but i am unsure of how to use this is my code. below is the code where i would like to place it. i would be very grateful if you could point me in the direction as to where i should be placing this code.

List<object> param = new List<object>();
                param.Add(CompanyData.CompanyIdColumnName);
                DataTable consumerCompany = Globals.GetDataTable("Query Name",
                    param, new string[] { });
                 
            string companyId = consumerCompany.Rows[0]["Company_Id"].ToString();
               
               Globals.ShowForm("Form Name", null);
               PrimaryDataRow["Company_Id"] = companyId;

Offline Saurav Jaiswal

  • Hero Member
  • *****
  • Posts: 115
  • Karma: +30/-0
  • Gender: Male
    • View Profile
Re: Type of Value Mismatches
« Reply #3 on: December 13, 2012, 09:58:25 AM »
Rahul,
From your example I understand that you are trying to open a company record based on the ID value present in some other table. Here the expected datatype is Id (from Class CDCSoftware.Pivotal.Engine)
Instead of declaring the variable as string, please declare it as Id. This should resolve your problem.

Id companyID = ID.Create(ConsumerCompany.Rows[0]["Company_ID"])

Regards
Saurav
Regards
Saurav
Infosys Limited