1
I find the following error when trying to update a table:
the data type text and varchar are incompatible with Equal Operator.
I have done several searches and most indicate the same solution: change the field to varchar(max)
. Problem: the field is already varchar(30) and does not even refer to a field of the type Text
Follows the code of update
:
public void updateAcaoEstado(string _stp, string _estado)
{
try
{
bo updtreg = (from bo in db.bos where (bo.bostamp == _stp && bo.ndos == 70) select bo).Single();
updtreg.cxusername = _estado;
updtreg.dtclose = DateTime.Today;
this.db.SubmitChanges();
}
catch (Exception ex)
{
throw ex;
}
}
Explanation of the fields:
- bo.bostamp -> Primary key - char(25)
- dtclose -> datetime
- cxusername -> varchar(30)
They’re all well-mapped in the file. Some help?
[UPDATE]
Follow the field mapping image cxusername
[UPDATE 2]
Query extracted from profiler
exec sp_executesql N'UPDATE [dbo].[bo]
SET [dtclose] = @p36, [cxusername] = @p37
WHERE ([obrano] = @p0) AND ([boano] = @p1) AND ([ndos] = @p2) AND ([bostamp] = @p3) AND ([nmdos] = @p4) AND ([dataobra] = @p5) AND ([nome] = @p6) AND ([etotaldeb] = @p7) AND ([estab] = @p8) AND ([no] = @p9) AND ([obranome] = @p10) AND ([dataopen] = @p11) AND (NOT ([fechada] = 1)) AND ([dtclose] = @p12) AND ([site] = @p13) AND ([datafecho] = @p14) AND ([datafinal] = @p15) AND ([tabela1] = @p16) AND ([trab2] = @p17) AND ([trab1] = @p18) AND ([series] = @p19) AND ([series2] = @p20) AND ([trab4] = @p21) AND ([quarto] = @p22) AND ([trab3] = @p23) AND ([obs] = @p24) AND ([ousrinis] = @p25) AND ([ousrdata] = @p26) AND ([ousrhora] = @p27) AND ([usrinis] = @p28) AND ([usrdata] = @p29) AND ([usrhora] = @p30) AND ([cxusername] = @p31) AND ([ultfact] = @p32) AND ([vendedor] = @p33) AND ([vendnm] = @p34) AND ([segmento] = @p35)',N'@p0 decimal(10,0),
@p1 decimal(4,0),@p2 decimal(3,0),@p3 char(25),@p4 varchar(8000),@p5 datetime,@p6 char(55),@p7 decimal(19,6),@p8 decimal(3,0),@p9 decimal(10,0),@p10 varchar(8000),
@p11 datetime,@p12 datetime,@p13 varchar(8000),@p14 datetime,@p15 datetime,@p16 varchar(8000),@p17 varchar(8000),@p18 varchar(8000),@p19 varchar(8000),@p20 varchar(8000),@p21 varchar(8000),@p22 varchar(8000),@p23 varchar(8000),@p24 varchar(8000),@p25 varchar(8000),@p26 datetime,@p27 varchar(8000),@p28 varchar(8000),@p29 datetime,@p30 varchar(8000),@p31 varchar(8000),@p32 datetime,@p33 decimal(4,0),@p34 varchar(8000),@p35 varchar(8000),@p36 datetime,@p37 varchar(8000)',
@p0=6,@p1=2019,@p2=70,@p3='882a1f84-fbec-40e1-be9c-5',@p4='00-Acções CRM',@p5='2019-10-22 00:00:00',@p6='3ELEVEN LIMITED',@p7=0,@p8=0,@p9=499,@p10='',@p11='2019-10-28 00:00:00',@p12='1900-01-01 00:00:00',@p13='1834',@p14='1900-01-01 00:00:00',@p15='2019-10-30 00:00:00',@p16='Reunião',@p17='Prospecção',@p18='sdffsd',@p19='sdffsddfs',@p20='sdfsdfsdf',@p21='Roriz não tem interesse no cliente',@p22='Cliente',@p23='',@p24='',@p25='ADM',@p26='2019-10-22 00:00:00',@p27='',@p28='ADM',@p29='2019-10-22 00:00:00',@p30='',
@p31='Agendada',@p32='2019-10-31 00:00:00',@p33=22,@p34='',@p35='',@p36='2019-10-23 00:00:00',
@p37='Realizado'
Is the string that is trying to record nocxusername really less than 30 characters? Do you have mapping class also correct? Could you post?
– Victor Laio
The string I’m trying to record is "Accomplished"....
– Adriano Maia
Is there any validation in the model?
– Victor Laio
I put the mapping image
– Adriano Maia
Place the class to which the cxusername property belongs.
– Victor Laio
Another thing I forgot to mention, I have one
insert
which works properly, theupdate
is that not– Adriano Maia
What class are you referring to,
layout
ordesigner
?– Adriano Maia
Where it is declared
public string cxusername { get; set; }
– Victor Laio
The
LINQ
is what this abstraction is about, I simply do the mapping according to what is in the database.. That is, the attributecxusername
is inserted inside the tablebo
i just have to call table bo in the fileLinq2SQL
(name I gave), later creating theclasse
with the intended methods– Adriano Maia
If necessary, I can put the file code here
dbml
.– Adriano Maia
@Adrianomaia, have you checked the query that is being generated? Could you ask the question?
– George Wurthmann
@Georgewurthmann already put the query extracted from
profiler
, if useful– Adriano Maia
@Georgewurthmann I have two attributes mapped with varchar(max)
– Adriano Maia