Forums: [SOLVED] HTTP 500 checking IF EXIST - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[SOLVED] HTTP 500 checking IF EXIST Rate Topic: -----

#1 User is offline   VORONOY 

  • Member
  • PipPip
  • Group: Members
  • Posts: 19
  • Joined: 14-February 07

Posted 24 November 2017 - 08:27 PM

I have two tables in 2 databases on different servers. I am trying to check if "ID"=data("SOMEID") exist in second "USERS" table and if does not exist - make cell red.
Im getting HTTP 500 error with code below. If I use WHERE ID=12345 and not data("SOMEID") it works well for that ID.

Am I typing wrong syntax for rs.Open "select ID from USERS WHERE ID=" & data("SOMEID") &"", conn???

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB;Server=SERVER;Uid=USER;Pwd=PASSWORD;Database=TEST"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select ID from USERS WHERE ID=" & data("SOMEID") &"", conn
If data("SOMEID")<>rs("ID") then
record("SOMEID_style") = "style=""background:red"""
end if



Thank you!
0

#2 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 15491
  • Joined: 03-February 03

Posted 25 November 2017 - 03:03 PM

I recommend to enable detailed error messages in IIS settings. This way you can see the actual error message and fix your code quicker.
Best regards,
Sergey Kornilov
0

#3 User is offline   VORONOY 

  • Member
  • PipPip
  • Group: Members
  • Posts: 19
  • Joined: 14-February 07

Posted 30 November 2017 - 09:33 PM

View PostVORONOY, on 24 November 2017 - 03:27 PM, said:

I have two tables in 2 databases on different servers. I am trying to check if "ID"=data("SOMEID") exist in second "USERS" table and if does not exist - make cell red.
Im getting HTTP 500 error with code below. If I use WHERE ID=12345 and not data("SOMEID") it works well for that ID.

Am I typing wrong syntax for rs.Open "select ID from USERS WHERE ID=" & data("SOMEID") &"", conn???

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB;Server=SERVER;Uid=USER;Pwd=PASSWORD;Database=TEST"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select ID from USERS WHERE ID=" & data("SOMEID") &"", conn
If data("SOMEID")<>rs("ID") then
record("SOMEID_style") = "style=""background:red"""
end if



Thank you!



Was wrong syntax. This fixes it:

rs.Open "select ID from USERS WHERE ID='"&data("SOMEID")&"'", conn
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic