visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: ASP :: VBS :: How to perform a simple SQL query to Oracle in ASP ? Tutorial ? Example ?


By: Bernard France  Date: 13/04/2005 10:02:28  English  Points: 20 Status: Answered
Quality : Excellent
Do you have any clue ?
By: VGR Date: 13/04/2005 10:11:50 English  Type : Comment
something like this ?

To retrieve a count(*) :

Set dbObj = Server.CreateObject("ADODB.CONNECTION") Set dbRst = Server.CreateObject("ADODB.RECORDSET") dbObj.Open strdbADSLQ sField = "COUNT(ID)" 'Retrieve the number of records strSQL = "SELECT COUNT(id) FROM ADSL_QUEUE_STATES WHERE account_id = " & strSearchAccId dbRst.Open strSQL, dbObj, 3, 3 strCurrentRecordCount = dbRst.Fields(sField) dbRst.Close Set dbRst = Nothing Set dbObj = Nothing



and to retrieve actual data :

Set dbObj = Server.CreateObject("ADODB.CONNECTION") Set dbRst = Server.CreateObject("ADODB.RECORDSET") dbObj.Open strdbADSLQ strSQL = "SELECT q.id ,q.account_id,q.last_change,i.firstname,i.lastname,r.adsl_phone, b.b2b_flag, b.rejection_cause FROM ADSL_QUEUE_STATES q, ADSL_INVOICE_DATA i, ADSL_REQUEST_DATA r, ADSL_BELGACOM_DATA b WHERE q.account_id = i.account_id AND q.account_id = r.account_id AND q.account_id = b.account_id AND q.account_id = " & strSearchAccId & " ORDER BY LAST_CHANGE ASC" dbRst.Open strSQL, dbObj, 3, 3 If dbRst.EOF and dbRst.BOF Then ' no data found, do whatever HTML output you wish %> <tr> <td bgcolor="#F5F5F5" colspan="5">Could not find any requests for the current state (<%=strStateName%>) or search.</td> </tr> <% Else 'Begin loop Do dbRst.MoveNext 'here process line read ' REM you read a column via Trim(dbRst("HOUSE_NUMBER")) Loop While dbRst.EOF = False End If dbRst.Close dbObj.Close Set dbRst = Nothing Set dbObj = Nothing


By: Bernard Date: 14/04/2005 09:44:23 English  Type : Comment
thanks. I suppose I need some kind of DSN file for accessing the database via the symbolical name strdbADSLQ like in dbObj.Open strdbADSLQ ?

How do I define this ?
By: VGR Date: 14/04/2005 09:53:23 English  Type : Comment
Absolutely, and there it is :

in fact, "strdbADSLQ" is defined in a previous include as :

strdbADSLQ = "File Name=d:\adslq.udl"



and the contents of this 'UDL' file are :

[oledb] ; Everything after this line is an OLE DB initstring Provider=MSDAORA.1;Password=withdrawn;User ID=armand;Data Source=someserver;Persist Security Info=True



In its turn, "someserver" has to be defined on your machine (hosts file ? SQL-Server equivalent of "tnsnames.ora" of Oracle ? Or "control panel/administrative tools/configure data sources (ODBC)" ? don't know)

good luck
By: Bernard Date: 25/04/2005 09:52:39 English  Type : Answer
very nice and very complete, thanks a lot :)

Do register to be able to answer

EContact
browser fav
page generated in 340.624090 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page