Languages :: ASP :: VBS :: How to perform a simple SQL query to Oracle in ASP ? Tutorial ? Example ? |
|||
| By: Bernard |
Date: 13/04/2005 10:02:28 |
Points: 20 | Status: Answered Quality : Excellent |
| Do you have any clue ? | |||
| By: VGR | Date: 13/04/2005 10:11:50 | 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 | 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 | 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 | Type : Answer |
|
| very nice and very complete, thanks a lot :) | |||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








