I started performing a program in classic asp and in a part of this program I wrote the following code:
<%
SQL = " SELECT Id = TCD.Id "_
& " , IdTipoContrato = TC.IdTipoContrato "_
& " , Codigo = TCD.Codigo "_
& " , Mercado = M.Mercado "_
& " , Empresa = M.EmpresaBD "_
& " , Valor = TCD.Valor " _
& " , Descricao = TCD.Descricao "_
& " , Moeda = MDS.Moeda "_
& " , Ativo = TCD.Ativo "_
& " FROM LI_TipoContratosDetalhe TCD WITH (NOLOCK) "_
& " INNER JOIN LI_TipoContratos TC WITH (NOLOCK) ON TCD.IdTipoContrato = TC.IDtipocontrato "_
& " INNER JOIN LI_Mercado M WITH (NOLOCK) ON TCD.Mercado = M.Mercado and TCD.Empresa = M.EmpresaBD"_
& " LEFT JOIN LI_Moedas MDS WITH (NOLOCK) ON TCD.Moeda = MDS.Moeda "_
& " WHERE TC.IdTipoContrato = " & Request("IdTipoContrato") & " " _
& " ORDER BY TCD.Id " _
& " , TC.IdTipoContrato "
rs.Open safeSQL(SQL), con, 1, 1
NLinhas = rs.RecordCount
'numLinhaAtual = 1
While not rs.EOF
%>
When I open the page (along with the rest of the code that is not displayed) I get the following error:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near the keyword 'ORDER'.
/GIP-eP/administrativo/contratos/gestaoTipoContratos.asp, line 915
What am I doing wrong ??
Thank you in advance for the help!
I did a Response.Write SQL and got this
SELECT Id = TCD.Id , IdTipoContrato = TC.IdTipoContrato , Codigo = TCD.Codigo , Mercado = M.Mercado , Empresa = M.EmpresaBD , Valor = TCD.Valor , Descricao = TCD.Descricao , Moeda = MDS.Moeda , Ativo = TCD.Ativo FROM LI_TipoContratosDetalhe TCD WITH (NOLOCK) INNER JOIN LI_TipoContratos TC WITH (NOLOCK) ON TCD.IdTipoContrato = TC.IDtipocontrato INNER JOIN LI_Mercado M WITH (NOLOCK) ON TCD.Mercado = M.Mercado and TCD.Empresa = M.EmpresaBD LEFT JOIN LI_Moedas MDS WITH (NOLOCK) ON TCD.Moeda = MDS.Moeda WHERE TC.IdTipoContrato = ORDER BY TCD.Id , TC.IdTipoContrato
I do not know are referring to this, I'm still a little new to it
I have already corrected the code now the ContractType is already entered correctly:
SELECT Id = TCD.Id , Codigo = TCD.Codigo , Mercado = M.Mercado , Empresa = M.EmpresaBD , Valor = TCD.Valor , Descricao = TCD.Descricao , Moeda = MDS.Moeda , Ativo = TCD.Ativo FROM LI_TipoContratosDetalhe TCD WITH (NOLOCK) INNER JOIN LI_TipoContratos TC WITH (NOLOCK) ON TCD.IdTipoContrato = TC.IDtipocontrato INNER JOIN LI_Mercados M WITH (NOLOCK) ON TCD.Mercado = M.Mercado and TCD.Empresa = M.EmpresaBD LEFT JOIN LI_Moedas MDS WITH (NOLOCK) ON TCD.Moeda = MDS.Moeda WHERE TC.IdTipoContrato = 3 ORDER BY TCD.Codigo
Thank you