All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Quick Search for:  in language:    
SQL,sample,shows,retrieve,TEXTIMAGE,fields,fr
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 281,486. lines
 Jobs: 101. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login

NEW! LEARNING CENTER
Special educational offers, white papers, webcasts, podcasts

  NEW! Download Rational Performance Tester V8 (download now)
  NEW! Download Rational Functional Tester V8 (download now)
  NEW! Download Rational Service Tester for SOA Quality V8 (download now)
  NEW! Teleconference: Quality In Action - Using Rational Quality Manager with Functional, Performance and Web Service Testing Products (download now)
  NEW! Introducing IBM Rational AppScan Developer Edition – easing security testing by non-security professionals (download now)

 

 


Latest postings for ASP/ VbScript.
Click here to see a screenshot of this code!Mess Officer Management System (Sistem Pengurusan Mess Pegawai)
By Mohd Fauzi on 11/23

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

Retrieve Text/Image fields from the database using OpenX

Print
Email
 
VB icon
Submitted on: 4/15/2001 5:18:37 PM
By: OpenX  
Level: Beginner
User Rating: Unrated
Compatibility:ASP (Active Server Pages)

Users have accessed this code 7654 times.
 
author picture
(About the author)
 
     This sample shows how to retrieve TEXT/IMAGE fields from the database using OpenX v2.0 for MS SQL Server.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: Retrieve Text/Image fields from 
    '     the database using OpenX
    ' Description:This sample shows how to r
    '     etrieve TEXT/IMAGE fields from the datab
    '     ase using OpenX v2.0 for MS SQL Server. 
    '     
    ' By: OpenX
    '
    ' Assumes:This sample uses OpenX v2.0 fo
    '     r MS SQL Server and Microsoft pubs datab
    '     ase. OpenX component available from http
    '     ://www.openx.ca.
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=6597&lngWId=4    'for details.    '**************************************
    
    <%@ Language=VBScript %>
    <%
    Set oConn = Server.CreateObject("OpenX2.Connection")
    Set oCommand = Server.CreateObject("OpenX2.Command")
    Dim sResult, sRetrieveSQL, sSetTextSize
    Dim bError
    Dim i
    sSetTextSize = "SET TEXTSIZE "
    sRetrieveSQL = "SELECT publishers.pub_name, publishers.city, publishers.state, publishers.country, pub_info.pub_id, pub_info.pr_info FROM pub_info, publishers WHERE ( pub_info.pub_id = publishers.pub_id ) ORDER BY publishers.pub_name"
    On Error Goto 0
    Sub ProcessErr
    if Err.number <> 0 Then
    bError = True
    sResult = ""
    if oConn.ErrorCode <> 0 Then
    sResult = "OpenX2 Connection Error: " & oConn.ErrorInfo & ". Error #" & oConn.ErrorCode & " (" & oConn.ErrorCodeEx & ")<BR />"
    Else
    if oCommand.ErrorCode <> 0 Then
    sResult = "OpenX2 Command Error: " & oCommand.ErrorInfo & ". Error #" & oCommand.ErrorCode & " (" & oCommand.ErrorCodeEx & ")<BR />"
    End if
    End if
    if sResult = "" Then
    Rem you may reRaise the Error here if yo
    '     u want to allow IIS process rest of erro
    '     rs
    sResult = "ASP Error: #" & CStr(Err.Number) & ". " & Err.description & "<BR />"
    End if
    End if
    End Sub
    Sub ProcessQuery
    i = 0
    oConn.Connect("ms_ox1")
    oCommand.Connection = oConn
    oConn.autoCommit = True
    oCommand.CommandText = sSetTextSize & "12000"
    oCommand.Execute
    oCommand.CommandText = sRetrieveSQL
    oCommand.Execute
    Do While oCommand.MoveNext
    sResult = sResult & "<TR>"
    sResult = sResult & "<TD style='font-size: 10pt; cursor: hand;' onClick='ShowDesc(row" & oCommand.FieldValueAsString(5) & ")'><B>Show/Hide Info</B></TD>"
    sResult = sResult & "<TD style='font-size: 10pt;'>" & oCommand.FieldValueAsString(1) & " </TD>"
    sResult = sResult & "<TD style='font-size: 10pt;'>" & oCommand.FieldValueAsString(2) & " </TD>"
    sResult = sResult & "<TD style='font-size: 10pt;'>" & oCommand.FieldValueAsString(3) & " </TD>"
    sResult = sResult & "<TD style='font-size: 10pt;'>" & oCommand.FieldValueAsString(4) & " </TD>"
    sResult = sResult & "</TR>"
    sResult = sResult & "<TR id='row" & oCommand.FieldValueAsString(5) & "' class='hiddentr'>"
    sResult = sResult & "<TD colspan='5'>" & oCommand.FieldValueAsString(6) & " </TD>"
    sResult = sResult & "</TR>"
    i = i + 1
    if i = 3 Then
    Exit Do
    End if
    Loop
    oCommand.CommandText = sSetTextSize & "0"
    oCommand.Execute
    End Sub
    REM // Main Processing
    On Error Resume Next
    ProcessQuery
    ProcessErr
    %>
    <HTML>
    <HEAD><TITLE>OpenX2 Test #10 - TEXT (CLOb/LongChar) Fields Reading </TITLE>
    <STYLE TYPE="text/css">
    tr.visibletr { font-size: 8pt; visibility: visible; position: static; }
    tr.hiddentr { font-size: 8pt; visibility: hidden; position: absolute; }
    </STYLE>
    <SCRIPT type="text/javascript" language="JavaScript">
    <!--
    function ShowDesc(theTR)
    {
    if(theTR) {
    if(theTR.className == "visibletr")
    theTR.className = "hiddentr";
    else
    theTR.className = "visibletr";
    }
    }
    -->
    </SCRIPT>
    </HEAD>
    <BODY>
    <TABLE border="1">
    <TR>
    	<TD><B>Info</B></TD>
    	<TD><B>Name</B></TD>
    	<TD><B>City</B></TD>
    	<TD><B>State</B></TD>
    	<TD><B>Country</B></TD>
    </TR>
    <%=sResult%>
    </TABLE>
    </BODY>
    </HTML>
    ASP file To retrieve image from the database (OX2ImageVB.asp)
    <%@ Language=VBScript %>
    <%
    Set oConn = Server.CreateObject("OpenX2.Connection")
    Set oCommand = Server.CreateObject("OpenX2.Command")
    Dim sResult, sRetrieveSQL, sSetTextSize
    Dim bError
    Dim pub_id
    pub_id = Request("pub_id")
    sSetTextSize = "SET TEXTSIZE "
    sRetrieveSQL = "SELECT pub_info.logo FROM pub_info WHERE pub_info.pub_id = '" & pub_id & "'"
    On Error Goto 0
    Sub ProcessErr
    if Err.number <> 0 Then
    bError = True
    sResult = ""
    if oConn.ErrorCode <> 0 Then
    sResult = "OpenX2 Connection Error: " & oConn.ErrorInfo & ". Error #" & oConn.ErrorCode & " (" & oConn.ErrorCodeEx & ")<BR />"
    Else
    if oCommand.ErrorCode <> 0 Then
    sResult = "OpenX2 Command Error: " & oCommand.ErrorInfo & ". Error #" & oCommand.ErrorCode & " (" & oCommand.ErrorCodeEx & ")<BR />"
    End if
    End if
    if sResult = "" Then
    Rem you may reRaise the Error here if yo
    '     u want to allow IIS process rest of erro
    '     rs
    sResult = "ASP Error: #" & CStr(Err.Number) & ". " & Err.description & "<BR />"
    End if
    End if
    End Sub
    Sub ProcessQuery
    oConn.Connect("ms_ox1")
    oCommand.Connection = oConn
    oConn.autoCommit = True
    oCommand.CommandText = sSetTextSize & "32768"
    oCommand.Execute
    oCommand.CommandText = sRetrieveSQL
    oCommand.Execute
    if Not oCommand.isEmpty Then
    Response.Clear
    Response.ContentType = "image/gif"
    Response.BinaryWrite(oCommand.FieldValueAsBinary(1))
    End if
    oCommand.CommandText = sSetTextSize & "0"
    oCommand.Execute
    End Sub
    REM // Main Processing
    On Error Resume Next
    ProcessQuery
    ProcessErr
    %>


Other 1 submission(s) by this author

 

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2008 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.