Link to home
Start Free TrialLog in
Avatar of nagib
nagib

asked on

Error Type: Microsoft VBScript runtime (0x800A01A8) - Object required:

<!--#include file="inc_conn.asp"-->

<%
Dim strSQL, rs, cmd
Dim bem
flag = false


'codigo = request.QueryString("bem")

strSQL = "select cidade.descricao as cidadedesc, bem.codigo as BemCodigo, bairro.descricao as bairrodesc, bem.endereco, bem.complemento, bem.valor_venda, bem.descricao, bem.modalidade , bem.tipo , bem.n_quartos, bem.n_suites, bem.n_vagas_carro, bem.valor_mensal, bem.valor_condominio, bem.m2 from cidade join bem on bem.idcidade = cidade.codigo join bairro on bairro.codigo = bem.idbairro where web_locar = 1 or web_vender = 1 and Bem.Codigo = "& bem

set cmd = Server.CreateObject("ADODB.Command")
set cmd.ActiveConnection = conn
cmd.CommandText = strSQL
set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.CursorType = 0
set rs = cmd.Execute

%>
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

We need to know which line is throwing the error. I assume "conn" is being created in your include file, but it may be worth checking its contents to make sure it is creating the connection properly.
Avatar of nagib
nagib

ASKER

<!--#include file="inc_conn.asp"-->

<%
Dim strSQL, rs, cmd
Dim bem
flag = false


'codigo = request.QueryString("bem")

strSQL = "select cidade.descricao as cidadedesc, bem.codigo as BemCodigo, bairro.descricao as bairrodesc, bem.endereco, bem.complemento, bem.valor_venda, bem.descricao, bem.modalidade , bem.tipo , bem.n_quartos, bem.n_suites, bem.n_vagas_carro, bem.valor_mensal, bem.valor_condominio, bem.m2 from cidade join bem on bem.idcidade = cidade.codigo join bairro on bairro.codigo = bem.idbairro where web_locar = 1 or web_vender = 1 and Bem.Codigo = "& bem

set cmd = Server.CreateObject("ADODB.Command")
set cmd.ActiveConnection = conn
cmd.CommandText = strSQL
set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.CursorType = 0
set rs = cmd.Execute

response.write rs(bem.codigo)   'THIS LINE IS THROWING THE ERROR
'response.write rs(bem.codigo)
response.end

%>
Aah, you need to put the name of the column in quotes:

    Response.Write rs("bem.codigo")
Avatar of nagib

ASKER

INC_CONN.ASP FILE

<%
Dim conn
      set conn = server.CreateObject("ADODB.Connection")

      with conn
            .connectionstring = "Provider=SQLOLEDB.1;Password=**********;Persist Security Info=False;User ID=sa;Initial Catalog=Simobil_Etica;Data Source=nma\nma"
            .open
      end with

%>
nagib,

If Carl's solution doesn't work then try using the alias instead.  You set up bem.codigo to the alias BemCodigo.  Try using the line below.

Response.Write rs("BemCodigo")

At least partial credit to Carl though because the missing quotes were a problem even if the alias works.

Let me know if you have any questions or need more information.

b0lsc0tt
Ah so he did, didn't notice that. I should probably read the question properly rather than just scanning it :o)
Avatar of nagib

ASKER

Now I get
ADODB.Recordset (0x800A0CC1)
and changing to the alias it worked, but gave me the wrong answer to the response.write rs("BemCodigo") this is my major problem.
Its returning 21 while it shoud return 1254....
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nagib

ASKER

Guys,
The strSQL was returning a large number of lines and the line number one had the BemCodigo=21.
I changes the strSQL to:

strSQL = "select cidade.descricao as cidadedesc, bem.codigo, bairro.descricao as bairrodesc, bem.endereco, bem.complemento, bem.valor_venda, bem.descricao, bem.modalidade , bem.tipo , bem.n_quartos, bem.n_suites, bem.n_vagas_carro, bem.valor_mensal, bem.valor_condominio, bem.m2 from cidade join bem on bem.idcidade = cidade.codigo join bairro on bairro.codigo = bem.idbairro where (web_locar = 1 or web_vender = 1) and bem.codigo = "& bem

I added the parentesis to solve the problem.

Thanks.

Who should I give the credit to ?  I think I should give to CARL_TAWN....