I am having a problem with my VBscript while interacting with an SQL database.
I have created two classes in vbs, one which is basically a wrapper for all of the database objects and the other an object that outputs HTML code to a web browser, this question is less an ASP question than a VB question so this is why I posted it in this forum.
When I make a query to the database, I do it with a function of the database class, here is the function (within the class):
class database
private conn
private rs
private sql
'=========================
'CONSTRUCTORS/DESTRUCTORS
'=========================
private sub class_initialize()
set conn = server.createObject("ADODB.Connection")
conn.ConnectionTimeout = 30
conn.CommandTimeout = 30
conn.open Application ("WebConn")
end sub
private sub class_terminate()
conn.close
end sub
public function setString(str)
sql = str
end function
public function execQuery()
set execQuery = conn.execute(sql)
end function
end class
I use the object in my main like this:
dim rs
dim db
set db = new database
db.setString("SELECT * FROM hyperlink " _
+ "WHERE hyperlinkID=" & linkID)
set rs = db.execQuery()
when I try to access the records in the record set, here is what I do:
response.write ("SOURCE: " + rs(3) + "<br>")
response.write ("DESCRIPTION: " + rs(2) + "<br>")
NOW FOR THE WEIRD STUFF:
which ever attribute I try first (either index 2 or 3) only the first of the two print, so either the SOURCE or the DESCRIPTION, but never both at the same time, I have to comment the first out to print the second, so if I were to switch the indexes above, the DESCRIPTION would print, and the SOURCE would not, but when I comment out the DESCRIPTION when the index is switched to 2,3, the SOURCE will print.
What have I done incorrectly??
thanks,
--Bryan
I have created two classes in vbs, one which is basically a wrapper for all of the database objects and the other an object that outputs HTML code to a web browser, this question is less an ASP question than a VB question so this is why I posted it in this forum.
When I make a query to the database, I do it with a function of the database class, here is the function (within the class):
class database
private conn
private rs
private sql
'=========================
'CONSTRUCTORS/DESTRUCTORS
'=========================
private sub class_initialize()
set conn = server.createObject("ADODB.Connection")
conn.ConnectionTimeout = 30
conn.CommandTimeout = 30
conn.open Application ("WebConn")
end sub
private sub class_terminate()
conn.close
end sub
public function setString(str)
sql = str
end function
public function execQuery()
set execQuery = conn.execute(sql)
end function
end class
I use the object in my main like this:
dim rs
dim db
set db = new database
db.setString("SELECT * FROM hyperlink " _
+ "WHERE hyperlinkID=" & linkID)
set rs = db.execQuery()
when I try to access the records in the record set, here is what I do:
response.write ("SOURCE: " + rs(3) + "<br>")
response.write ("DESCRIPTION: " + rs(2) + "<br>")
NOW FOR THE WEIRD STUFF:
which ever attribute I try first (either index 2 or 3) only the first of the two print, so either the SOURCE or the DESCRIPTION, but never both at the same time, I have to comment the first out to print the second, so if I were to switch the indexes above, the DESCRIPTION would print, and the SOURCE would not, but when I comment out the DESCRIPTION when the index is switched to 2,3, the SOURCE will print.
What have I done incorrectly??
thanks,
--Bryan