0

I am trying to build a classic ASP (not asp.net ) page that can retrieve and insert data into a database. I followed some examples online and manage to connect to my database. This is the following code in my ASP page.

<!DOCTYPE html>
<html>
<body>
<%

Set Con= CreateObject("ADODB.Connection")
Con.ConnectionString= "Provider=SQLOLEDB; Data Source=PCNAME\SQLEXPRESS;Database=testing;User ID=sa;password=abcdefg"
Con.open

if IsObject(Con) then 
response.Write "The connection is active <br/>"

if Con.State=1 then
response.Write "A connection is made and is open <br/>"
end if

%>

</body>
</html>

When loaded, the asp page displays

"The connection is active A connection is made and is open"

Now, i want to create a recordset and extract data from it.

i add this snippet into my code,

set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn

But, when i load the page, i get the following results,

The connection is active A connection is made and is open An error occurred on the server when processing the URL. Please contact the system administrator.

If you are the system administrator please click here to find out more about this error.

Aristos
  • 66,005
  • 16
  • 114
  • 150
Yoong Tat
  • 85
  • 2
  • 11
  • Did u click and find more about the error ? – FakeisMe Sep 19 '16 at 08:27
  • yeap it led me to a page with some troubleshooting steps. It was too advanced for me to understand. – Yoong Tat Sep 19 '16 at 08:37
  • 1
    In Internet Explorer, on the Tools menu, click Internet Options. On the Advanced tab, under the Browsing section, click to clear the Show friendly HTTP error messages check box, and then click OK. Close the browser. – FakeisMe Sep 19 '16 at 08:39
  • After doing the above . please re-run your app and see what error you are getting. – FakeisMe Sep 19 '16 at 08:40
  • cant seem to find that option in both chrome and microsoft edge, i'm on windows 10 and there's no more IE. – Yoong Tat Sep 19 '16 at 08:53
  • @YoongTat I'm on Windows 10 *(upgraded )* and if you want IE other then Edge it's still there `"C:\Program Files\Internet Explorer\iexplore.exe"` just pin it to the taskbar or if it's not there *(clean Windows 10 install)* [download it](https://go.microsoft.com/fwlink/p/?linkid=290956). – user692942 Sep 19 '16 at 09:30
  • 1
    Also this error is probably coming from the server so disabling Friendly HTTP Error messages won't necessarily work instead you need to enable detailed errors on the IIS Server see http://stackoverflow.com/a/2765795/692942 and http://stackoverflow.com/a/2640607/692942 – user692942 Sep 19 '16 at 09:42

1 Answers1

0

Well, if the code you've submitted here is what you're really using, then you are getting a error because of the ADODB.Connection object, in the rs.Open line, the error description is:

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

Because you created a connection name Con and passed a conn to the second parameter of rs.Open, that expects a connection string or a connection object.

Read more here: http://www.w3schools.com/asp/met_rs_open.asp

Marco
  • 1,279
  • 1
  • 15
  • 26
  • Thank you for spotting out my mistake. I am very grateful. Its small mistakes and typos like this that can really disorient someone like me who's a beginner at coding. – Yoong Tat Sep 25 '16 at 08:00