views:

1766

answers:

3

Im getting an Exception when I try updating, Insert works perfectly.. so this is: A first chance exception of type 'System.InvalidCastException' occurred in System.Data.Linq.dll Another cue... is possible to insert in one table first and then update another table and finally submitchanges() all in same code-block? I also comment InsertOnSubmit(); and I Rebuild dbml (drop and create again) changed name, context etc.. Code :

using (DB db = new DB())
            {
                //db.ObjectTrackingEnabled = false;
                INFORMEMEDICO varInf = (from i in db.INFORMEMEDICOs
                                        where i.numeroinforme == codigo
                                        select i).SingleOrDefault();

                EXAMENXATENCION varExA = (from ea in db.EXAMENXATENCIONs
                                          where ea.codigo == codigo
                                          select ea).Single();

                if (varInf == null)
                {
                    varInf = new INFORMEMEDICO();
                    varInf.firmauno = getJPGFromImageControl(firmaUno.Source as BitmapImage);
                    varInf.firmados = getJPGFromImageControl(firmaDos.Source as BitmapImage);
                    varInf.tecnica = GetText(rtbTec);
                    varExA.estadoestudio = 'I';                    
                    try
                    {
                        db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
                        //db.INFORMEMEDICOs.InsertOnSubmit(varInf);
                        MessageBox.Show("Informe Medico Registrado con exito: " + "\n" + "Nro Informe :" + codigo);
                    }
                    catch (Exception ex)
                    {
                        sucessfull = 0;
                        MessageBox.Show("Error en Registro : " + ex.Message);
                    }



                }

Stack :

System.InvalidCastException was caught
  Message="No se puede convertir un objeto de tipo 'System.Int32' al tipo 'System.String'."
  Source="System.Data.Linq"
  StackTrace:
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2& k)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.IdentityCache`2.Find(Object[] keyValues)
       en System.Data.Linq.IdentityManager.StandardIdentityManager.Find(MetaType type, Object[] keyValues)
       en System.Data.Linq.CommonDataServices.GetCachedObject(MetaType type, Object[] keyValues)
       en System.Data.Linq.ChangeProcessor.GetOtherItem(MetaAssociation assoc, Object instance)
       en System.Data.Linq.ChangeProcessor.BuildEdgeMaps()
       en System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
       en System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
       en System.Data.Linq.DataContext.SubmitChanges()
       en Demo.View.InformeMedico.btnGuardar_Click(Object sender, RoutedEventArgs e) en D:\cs_InformeMedico\app\InformeMedico.xaml.cs:línea 433
  InnerException:

Thanks for yours continuos support

XML :

<?xml version="1.0" encoding="utf-8"?>
<ordesignerObjectsDiagram dslVersion="1.0.0.0" absoluteBounds="0, 0, 11.625, 14" name="DataClasses1">
  <DataContextMoniker Name="/DB" />
  <nestedChildShapes>
    <classShape Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" absoluteBounds="5.75, 1.25, 2, 3.23266845703125">
      <DataClassMoniker Name="/DB/EXAMENXATENCION" />
      <nestedChildShapes>
        <elementListCompartment Id="10f26c82-1f06-45d2-9488-da3d7d92e231" absoluteBounds="5.7650000000000006, 1.71, 1.9700000000000002, 2.67266845703125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="1f3a6a96-bcc1-41c3-8d57-b9987a3cdec1" absoluteBounds="2.625, 2.875, 2, 1.4248478190104168">
      <DataClassMoniker Name="/DB/ESTUDIO" />
      <nestedChildShapes>
        <elementListCompartment Id="86092ab5-554b-402d-a8cf-938b89f4473e" absoluteBounds="2.64, 3.335, 1.9700000000000002, 0.86484781901041674" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(4.625 : 3.58742390950521); (5.75 : 3.58742390950521)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/ESTUDIO/ESTUDIO_EXAMENXATENCION" />
      <nodes>
        <classShapeMoniker Id="1f3a6a96-bcc1-41c3-8d57-b9987a3cdec1" />
        <classShapeMoniker Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" />
      </nodes>
    </associationConnector>
    <classShape Id="e4ab888d-5eb4-4b81-a562-baa1ff7393f8" absoluteBounds="7.875, 5.625, 2, 2.5752791341145831">
      <DataClassMoniker Name="/DB/PACIENTE" />
      <nestedChildShapes>
        <elementListCompartment Id="239b98aa-995d-458c-b0e6-4211e108c99d" absoluteBounds="7.8900000000000006, 6.085, 1.9700000000000002, 2.015279134114583" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" absoluteBounds="1.625, 5, 2, 2.9039737955729166">
      <DataClassMoniker Name="/DB/ATENCION" />
      <nestedChildShapes>
        <elementListCompartment Id="c3ec622f-93e5-4418-bb4d-7903b46ac639" absoluteBounds="1.6400000000000001, 5.46, 1.9700000000000002, 2.3439737955729165" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(3.625 : 6.24307135546875); (4.07291666666667 : 6.24307135546875 : JumpStart); (4.23958333333333 : 6.24307135546875 : JumpEnd); (7.21875 : 6.24307135546875); (7.21875 : 4.48266845703125)]" manuallyRouted="true" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/ATENCION/ATENCION_EXAMENXATENCION" />
      <nodes>
        <classShapeMoniker Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" />
        <classShapeMoniker Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" />
      </nodes>
    </associationConnector>
    <associationConnector edgePoints="[(7.875 : 7.5486477109375); (4.23958333333333 : 7.5486477109375 : JumpStart); (4.07291666666667 : 7.5486477109375 : JumpEnd); (3.625 : 7.5486477109375)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/PACIENTE/PACIENTE_ATENCION" />
      <nodes>
        <classShapeMoniker Id="e4ab888d-5eb4-4b81-a562-baa1ff7393f8" />
        <classShapeMoniker Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" />
      </nodes>
    </associationConnector>
    <classShape Id="f479daef-94e3-451a-b060-f4644304ec8c" absoluteBounds="0.5, 0.5, 2, 2.4109318033854166">
      <DataClassMoniker Name="/DB/MEDICOEXTERNO" />
      <nestedChildShapes>
        <elementListCompartment Id="964d649c-c39e-48c6-b130-215c40080462" absoluteBounds="0.515, 0.96, 1.9700000000000002, 1.8509318033854165" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(2.0625 : 2.91093180338542); (2.0625 : 5)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/MEDICOEXTERNO/MEDICOEXTERNO_ATENCION" />
      <nodes>
        <classShapeMoniker Id="f479daef-94e3-451a-b060-f4644304ec8c" />
        <classShapeMoniker Id="516b8633-e8ba-43f7-bf23-8c18e055e9b4" />
      </nodes>
    </associationConnector>
    <classShape Id="5ce0ebb2-391e-46de-b85c-c6a50434ea12" absoluteBounds="3.125, 0.5, 2, 1.26050048828125">
      <DataClassMoniker Name="/DB/FIRMA" />
      <nestedChildShapes>
        <elementListCompartment Id="a21918ee-6f48-470d-9f0e-a9160faab27e" absoluteBounds="3.1399999999999997, 0.96, 1.9700000000000002, 0.70050048828125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="8080f6a7-cd0f-4e38-a667-8aa34c40969e" absoluteBounds="5.375, 9, 2, 1.9178898111979166">
      <DataClassMoniker Name="/DB/PLANTILLA" />
      <nestedChildShapes>
        <elementListCompartment Id="b6606488-da97-4a5c-9204-1c1874f1fb29" absoluteBounds="5.39, 9.46, 1.9700000000000002, 1.3578898111979165" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <classShape Id="2ecb0a31-9312-4243-9d5a-dcecc886146c" absoluteBounds="1.375, 8.875, 2, 1.75354248046875">
      <DataClassMoniker Name="/DB/EQUIPO" />
      <nestedChildShapes>
        <elementListCompartment Id="b72b559d-fea0-4615-a2ac-08b4dc715230" absoluteBounds="1.3900000000000001, 9.335, 1.9700000000000002, 1.19354248046875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(3.375 : 8.90625); (4.07291666666667 : 8.90625 : JumpStart); (4.23958333333333 : 8.90625 : JumpEnd); (7.59375 : 8.90625); (7.59375 : 4.48266845703125)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/EQUIPO/EQUIPO_EXAMENXATENCION" />
      <nodes>
        <classShapeMoniker Id="2ecb0a31-9312-4243-9d5a-dcecc886146c" />
        <classShapeMoniker Id="578a0699-bcf4-45c5-9bec-2beb667a6a06" />
      </nodes>
    </associationConnector>
    <classShape Id="8a332fc0-58f9-4d58-ae99-d84b9ef09d01" absoluteBounds="9.375, 10.5, 2, 3.23266845703125">
      <DataClassMoniker Name="/DB/INFORMEMEDICO" />
      <nestedChildShapes>
        <elementListCompartment Id="2696f44c-b32e-4a93-b012-c19292012a86" absoluteBounds="9.39, 10.96, 1.9700000000000002, 2.67266845703125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
      </nestedChildShapes>
    </classShape>
    <associationConnector edgePoints="[(9.625 : 8.20027913411458); (9.625 : 10.5)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/PACIENTE/PACIENTE_INFORMEMEDICO" />
      <nodes>
        <classShapeMoniker Id="e4ab888d-5eb4-4b81-a562-baa1ff7393f8" />
        <classShapeMoniker Id="8a332fc0-58f9-4d58-ae99-d84b9ef09d01" />
      </nodes>
    </associationConnector>
    <associationConnector edgePoints="[(4.15625 : 4.29984781901042); (4.15625 : 12.3565291341146); (9.375 : 12.3565291341146)]" fixedFrom="NotFixed" fixedTo="NotFixed">
      <AssociationMoniker Name="/DB/ESTUDIO/ESTUDIO_INFORMEMEDICO" />
      <nodes>
        <classShapeMoniker Id="1f3a6a96-bcc1-41c3-8d57-b9987a3cdec1" />
        <classShapeMoniker Id="8a332fc0-58f9-4d58-ae99-d84b9ef09d01" />
      </nodes>
    </associationConnector>
  </nestedChildShapes>
</ordesignerObjectsDiagram>

XML : oh ooh :)

<?xml version="1.0" encoding="utf-8"?>
<Database Name="DATABASEGENERAL" EntityNamespace="Demo.View.Data" ContextNamespace="Demo.View" Class="DB" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007"&gt;
  <Connection Mode="AppSettings" ConnectionString="Data Source=192.168.0.3;Initial Catalog=DATABASEGENERAL;Integrated Security=True" SettingsObjectName="SRIMedico.Properties.Settings" SettingsPropertyName="DATABASEGENERALConnectionString1" Provider="System.Data.SqlClient" />
  <Table Name="dbo.EXAMENXATENCION" Member="EXAMENXATENCIONs">
    <Type Name="EXAMENXATENCION">
      <Column Name="codigo" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
      <Column Name="numeroatencion" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="numerocita" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigocompaniaseguro" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="ruc" Type="System.String" DbType="Char(11) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoequipo" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="horaatencion" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoclase" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigomodalidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigounidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="estadoestudio" Type="System.Char" DbType="Char(1) NOT NULL" CanBeNull="false" />
      <Column Name="prioridad" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Column Name="turnomedico" Type="System.String" DbType="Char(5)" CanBeNull="true" />
      <Association Name="ATENCION_EXAMENXATENCION" Member="ATENCION" ThisKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" OtherKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" Type="ATENCION" IsForeignKey="true" />
      <Association Name="EQUIPO_EXAMENXATENCION" Member="EQUIPO" ThisKey="codigoequipo" OtherKey="codigoequipo" Type="EQUIPO" IsForeignKey="true" />
      <Association Name="ESTUDIO_EXAMENXATENCION" Member="ESTUDIO" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="ESTUDIO" IsForeignKey="true" />
    </Type>
  </Table>
  <Table Name="dbo.ATENCION" Member="ATENCIONs">
    <Type Name="ATENCION">
      <Column Name="fechayhora" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="numeroatencion" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="cmp" Type="System.String" DbType="Char(6) NOT NULL" CanBeNull="false" />
      <Column Name="codigocompaniaseguro" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="ruc" Type="System.String" DbType="Char(11) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="numerocita" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigomodalidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigounidad" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="peso" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
      <Column Name="talla" Type="System.Single" DbType="Real NOT NULL" CanBeNull="false" />
      <Column Name="edad" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
      <Column Name="codigousuario" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Association Name="ATENCION_EXAMENXATENCION" Member="EXAMENXATENCIONs" ThisKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" OtherKey="numeroatencion,codigopaciente,codigomodalidad,codigounidad,codigocompaniaseguro,ruc,numerocita" Type="EXAMENXATENCION" />
      <Association Name="PACIENTE_ATENCION" Member="PACIENTE" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="PACIENTE" IsForeignKey="true" />
      <Association Name="MEDICOEXTERNO_ATENCION" Member="MEDICOEXTERNO" ThisKey="cmp" OtherKey="cmp" Type="MEDICOEXTERNO" IsForeignKey="true" />
    </Type>
  </Table>
  <Table Name="dbo.INFORMEMEDICO" Member="INFORMEMEDICOs">
    <Type Name="INFORMEMEDICO">
      <Column Name="numeroinforme" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="turnosocio" Type="System.String" DbType="Char(5) NOT NULL" CanBeNull="false" />
      <Column Name="fechainforme" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="horainforme" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="tecnica" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
      <Column Name="hallazgo" Type="System.String" DbType="VarChar(5000) NOT NULL" CanBeNull="false" />
      <Column Name="conclusion" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
      <Column Name="impreso" Type="System.Boolean" DbType="Bit NOT NULL" CanBeNull="false" />
      <Column Name="codigoclase" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="medicoinforma" Type="System.String" DbType="Char(5) NOT NULL" CanBeNull="false" />
      <Column Name="firmados" Type="System.Data.Linq.Binary" DbType="Image" CanBeNull="true" UpdateCheck="Never" />
      <Column Name="firmauno" Type="System.Data.Linq.Binary" DbType="Image" CanBeNull="true" UpdateCheck="Never" />
      <Column Name="nombreinforme" Type="System.String" DbType="VarChar(150) NOT NULL" CanBeNull="false" />
      <Association Name="ESTUDIO_INFORMEMEDICO" Member="ESTUDIO" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="ESTUDIO" IsForeignKey="true" />
      <Association Name="PACIENTE_INFORMEMEDICO" Member="PACIENTE" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="PACIENTE" IsForeignKey="true" />
    </Type>
  </Table>
  <Table Name="dbo.EQUIPO" Member="EQUIPOs">
    <Type Name="EQUIPO">
      <Column Name="fechaadquirio" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="intensidad" Type="System.Single" DbType="Real NOT NULL" CanBeNull="false" />
      <Column Name="modelo" Type="System.String" DbType="VarChar(40)" CanBeNull="true" />
      <Column Name="marca" Type="System.String" DbType="VarChar(40) NOT NULL" CanBeNull="false" />
      <Column Name="nombreequipo" Type="System.String" DbType="VarChar(35) NOT NULL" CanBeNull="false" />
      <Column Name="codigoequipo" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Association Name="EQUIPO_EXAMENXATENCION" Member="EXAMENXATENCIONs" ThisKey="codigoequipo" OtherKey="codigoequipo" Type="EXAMENXATENCION" />
    </Type>
  </Table>
  <Table Name="dbo.ESTUDIO" Member="ESTUDIOs">
    <Type Name="ESTUDIO">
      <Column Name="nombreestudio" Type="System.String" DbType="VarChar(100) NOT NULL" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoclase" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="indicacion" Type="System.String" DbType="VarChar(500)" CanBeNull="true" />
      <Association Name="ESTUDIO_EXAMENXATENCION" Member="EXAMENXATENCIONs" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="EXAMENXATENCION" />
      <Association Name="ESTUDIO_INFORMEMEDICO" Member="INFORMEMEDICOs" ThisKey="codigoestudio,codigoclase" OtherKey="codigoestudio,codigoclase" Type="INFORMEMEDICO" />
    </Type>
  </Table>
  <Table Name="dbo.PACIENTE" Member="PACIENTEs">
    <Type Name="PACIENTE">
      <Column Name="nacionalidad" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Column Name="direccion" Type="System.String" DbType="VarChar(80)" CanBeNull="true" />
      <Column Name="email" Type="System.String" DbType="VarChar(60)" CanBeNull="true" />
      <Column Name="celular" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Column Name="telefono" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" />
      <Column Name="fechanace" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
      <Column Name="sexo" Type="System.Char" DbType="Char(1) NOT NULL" CanBeNull="false" />
      <Column Name="nombres" Type="System.String" DbType="VarChar(35) NOT NULL" CanBeNull="false" />
      <Column Name="apellidos" Type="System.String" DbType="VarChar(45) NOT NULL" CanBeNull="false" />
      <Column Name="dni" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Column Name="codigopaciente" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Association Name="PACIENTE_ATENCION" Member="ATENCIONs" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="ATENCION" />
      <Association Name="PACIENTE_INFORMEMEDICO" Member="INFORMEMEDICOs" ThisKey="codigopaciente" OtherKey="codigopaciente" Type="INFORMEMEDICO" />
    </Type>
  </Table>
  <Table Name="dbo.MEDICOEXTERNO" Member="MEDICOEXTERNOs">
    <Type Name="MEDICOEXTERNO">
      <Column Name="cmp" Type="System.String" DbType="Char(6) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="apellidos" Type="System.String" DbType="VarChar(45) NOT NULL" CanBeNull="false" />
      <Column Name="nombres" Type="System.String" DbType="VarChar(35) NOT NULL" CanBeNull="false" />
      <Column Name="telefono" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Column Name="direccion" Type="System.String" DbType="VarChar(80)" CanBeNull="true" />
      <Column Name="email" Type="System.String" DbType="VarChar(60)" CanBeNull="true" />
      <Column Name="fechanacio" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
      <Column Name="codigoespecialidad" Type="System.Int32" DbType="Int" CanBeNull="true" />
      <Column Name="activo" Type="System.Boolean" DbType="Bit NOT NULL" CanBeNull="false" />
      <Column Name="celular" Type="System.String" DbType="VarChar(20)" CanBeNull="true" />
      <Association Name="MEDICOEXTERNO_ATENCION" Member="ATENCIONs" ThisKey="cmp" OtherKey="cmp" Type="ATENCION" />
    </Type>
  </Table>
  <Table Name="dbo.PLANTILLA" Member="PLANTILLAs">
    <Type Name="PLANTILLA">
      <Column Name="codigoplantilla" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="codigoequipo" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
      <Column Name="codigoestudio" Type="System.String" DbType="Char(12) NOT NULL" CanBeNull="false" />
      <Column Name="tituloplantilla" Type="System.String" DbType="VarChar(150) NOT NULL" CanBeNull="false" />
      <Column Name="tecnica" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
      <Column Name="hallazgo" Type="System.String" DbType="VarChar(5000) NOT NULL" CanBeNull="false" />
      <Column Name="conclusion" Type="System.String" DbType="VarChar(3000) NOT NULL" CanBeNull="false" />
    </Type>
  </Table>
  <Table Name="dbo.FIRMA" Member="FIRMAs">
    <Type Name="FIRMA">
      <Column Name="codigofirma" Type="System.String" DbType="VarChar(20) NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
      <Column Name="siglas" Type="System.String" DbType="Char(5) NOT NULL" CanBeNull="false" />
      <Column Name="imagen" Type="System.Data.Linq.Binary" DbType="Image NOT NULL" CanBeNull="false" UpdateCheck="Never" />
    </Type>
  </Table>
</Database>
A: 

Looks like your database schema doesn't match your DBML. Double check your property types and attributes match.

slf
I Just drag and drop from server explorer
Angel Escobedo
A: 

Is the estadoestudio Field from your EXAMENXATENCION Table a VarChar(1) ? if so the LINQ to SQL designer has interpreted this as a Char field, edit your column in your DBML designer or underlying XML to System.String instead of System.Char. I would also recommend this for any other VarChar(1) fields you are representing in LINQ to SQL if the field is nullable as you cannot have a null char.

Quintin Robinson
yes, is a State, like 'P' is Paid ...
Angel Escobedo
well, I open a new project with the same WPF App and then with one button update random row in a table from my database, and works! Is this a bug?
Angel Escobedo
Then you should just need to open your DBML designer, click on the columns that are defined as varchar(1) or nvarchar(1) in your DB and change the type in the properties window from System.Char to System.String
Quintin Robinson
I did it already, and error continues
Angel Escobedo
Bleh.. I should have read your error message better. It says int32 to string. Can you right click your DBML and say open with and select XML Viewer and paste the XML for the relevant tables as well as the SQL definitions so we can see where the mismatch is occuring?
Quintin Robinson
ok maybe this is a bug, I Have the same XML in both project (in working and not working ones)
Angel Escobedo
Well can't confirm or deny it's a bug, but I fail to see a problem from here. Hopefully you can salvage your elements into that new project that works correctly.
Quintin Robinson
A: 

Solution:

Open a new Project, add new Linq2SQL Model and then copy and paste XML and designer.cs file, rename on this line :

public DB() :
            base(global::SRIMedico.Properties.Settings.Default.DATABASEGENERALConnectionString, mappingSource)
        {
            OnCreated();
        }

where SRIMedico will be your Default Namespace... and DATABASEGENERALConnectionString will be your ConnectionString name..

Hopes help

Angel Escobedo