J
Jorge
Hello
I have been for the last 2 days for abnormal behavior
when try to refresh a datagrid from another form.
If Not (fenc Is Nothing) Then
'' Actualiza a datagrid2 do formenc
fenc.SqlDataAdapter4.SelectCommand.CommandType =
CommandType.Text
If Not fenc.RadioButton1.Checked Then
'' encomenda externa
fenc.SqlDataAdapter4.SelectCommand.CommandText = "select
artenc.pos , artenc.quant , artenc.codigo ,
familias.desfam , artigos.desart , artenc.nvias ,
artenc.id , artenc.punit , artenc.prev ,artenc.penc ,
artenc.zona , artenc.cor , artenc.prazo ,
artenc.refcliente ,
artenc.quant_exp ,artenc.nenc ,artenc.obra ,artenc.posobra
, estados.nome ,
artenc.desconto ,artenc.idcli ,artenc.obs_com ,
artenc.obs , artenc.obs_com2 ,artenc.margem ,artenc.tipo
from artigos, familias, artenc, estados where
artigos.cf=familias.cf and artigos.cf = convert
(int,substring(artenc.codigo,1,charindex
('.',artenc.codigo)-1)) and artigos.ca = convert
(int,substring(artenc.codigo,charindex('.',artenc.codigo)
+1,2)) and artenc.numenc = '" & fenc.TextBox1.Text & "'
and estados.codigo = artenc.estado order by artenc.pos
asc"
Else
'' fornecimento de material
fenc.SqlDataAdapter4.SelectCommand.CommandText = "select
artenc.pos Pos, artenc.quant Qtd, artenc.codigo Cod,
familias.desfam Familia, armazem.designacao Artigo,
artenc.nvias Vias, artenc.id Id, artenc.punit PCliente,
artenc.prev PEnc,artenc.penc PTab, artenc.zona Zona,
artenc.cor Cor, artenc.prazo Pz, artenc.refcliente
RfCliente, artenc.quant_exp QtExp,artenc.nenc
NEnc,artenc.obra Obra,artenc.posobra PosObra,
estados.nome Estado, artenc.desconto
Desconto,artenc.idcli IdCliente,artenc.obs_com ObsCom,
artenc.obs Obs, artenc.obs_com2 ObsCom2 ,artenc.margem
Margem,artenc.tipo Garantia from artigos, familias,
artenc, estados ,armazem where artigos.cf=familias.cf and
artigos.cf = convert (int,substring
(artenc.codigo,1,charindex('.',artenc.codigo)-1)) and
artigos.ca = convert(int,substring(artenc.codigo,charindex
('.',artenc.codigo)+1,2)) and artenc.numenc = '" &
fenc.TextBox1.Text & "' and estados.codigo =
artenc.estado and armazem.codigo = artenc.id order by
artenc.pos asc"
End If
fenc.SqlDataAdapter4.SelectCommand.Connection =
fenc.SqlConnection1
Dim dataset3 As New DataSet
fenc.SqlDataAdapter4.Fill
(dataset3, "artenc")
Console.WriteLine
(fenc.SqlDataAdapter4.SelectCommand.CommandText)
fenc.DataGrid2.DataSource =
dataset3.Tables("artenc")
fenc.DataGrid2.ReadOnly = True
--
fenc is reference to the caller form. The selectcommand
of the adapter has been raising a excpetion complaining
that a certain field doesn't belong to table artenc.
Sometimes its 'desconto','idcliente','estado',etc. but
they all belong to the table. And when i run the query in
query analyser it works ok and i haven't done any recent
changes in table artenc.
This doesn't make sense i am going crazy over this!!
Any sugestions ? Thanks
Kind Regards
Jorge
I have been for the last 2 days for abnormal behavior
when try to refresh a datagrid from another form.
If Not (fenc Is Nothing) Then
'' Actualiza a datagrid2 do formenc
fenc.SqlDataAdapter4.SelectCommand.CommandType =
CommandType.Text
If Not fenc.RadioButton1.Checked Then
'' encomenda externa
fenc.SqlDataAdapter4.SelectCommand.CommandText = "select
artenc.pos , artenc.quant , artenc.codigo ,
familias.desfam , artigos.desart , artenc.nvias ,
artenc.id , artenc.punit , artenc.prev ,artenc.penc ,
artenc.zona , artenc.cor , artenc.prazo ,
artenc.refcliente ,
artenc.quant_exp ,artenc.nenc ,artenc.obra ,artenc.posobra
, estados.nome ,
artenc.desconto ,artenc.idcli ,artenc.obs_com ,
artenc.obs , artenc.obs_com2 ,artenc.margem ,artenc.tipo
from artigos, familias, artenc, estados where
artigos.cf=familias.cf and artigos.cf = convert
(int,substring(artenc.codigo,1,charindex
('.',artenc.codigo)-1)) and artigos.ca = convert
(int,substring(artenc.codigo,charindex('.',artenc.codigo)
+1,2)) and artenc.numenc = '" & fenc.TextBox1.Text & "'
and estados.codigo = artenc.estado order by artenc.pos
asc"
Else
'' fornecimento de material
fenc.SqlDataAdapter4.SelectCommand.CommandText = "select
artenc.pos Pos, artenc.quant Qtd, artenc.codigo Cod,
familias.desfam Familia, armazem.designacao Artigo,
artenc.nvias Vias, artenc.id Id, artenc.punit PCliente,
artenc.prev PEnc,artenc.penc PTab, artenc.zona Zona,
artenc.cor Cor, artenc.prazo Pz, artenc.refcliente
RfCliente, artenc.quant_exp QtExp,artenc.nenc
NEnc,artenc.obra Obra,artenc.posobra PosObra,
estados.nome Estado, artenc.desconto
Desconto,artenc.idcli IdCliente,artenc.obs_com ObsCom,
artenc.obs Obs, artenc.obs_com2 ObsCom2 ,artenc.margem
Margem,artenc.tipo Garantia from artigos, familias,
artenc, estados ,armazem where artigos.cf=familias.cf and
artigos.cf = convert (int,substring
(artenc.codigo,1,charindex('.',artenc.codigo)-1)) and
artigos.ca = convert(int,substring(artenc.codigo,charindex
('.',artenc.codigo)+1,2)) and artenc.numenc = '" &
fenc.TextBox1.Text & "' and estados.codigo =
artenc.estado and armazem.codigo = artenc.id order by
artenc.pos asc"
End If
fenc.SqlDataAdapter4.SelectCommand.Connection =
fenc.SqlConnection1
Dim dataset3 As New DataSet
fenc.SqlDataAdapter4.Fill
(dataset3, "artenc")
Console.WriteLine
(fenc.SqlDataAdapter4.SelectCommand.CommandText)
fenc.DataGrid2.DataSource =
dataset3.Tables("artenc")
fenc.DataGrid2.ReadOnly = True
--
fenc is reference to the caller form. The selectcommand
of the adapter has been raising a excpetion complaining
that a certain field doesn't belong to table artenc.
Sometimes its 'desconto','idcliente','estado',etc. but
they all belong to the table. And when i run the query in
query analyser it works ok and i haven't done any recent
changes in table artenc.
This doesn't make sense i am going crazy over this!!
Any sugestions ? Thanks
Kind Regards
Jorge