ODBC Connection Problems

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default ODBC Connection Problems

    Im trying to use an example script to connect to an ODBC source and
    display the records in one table. This is a proprietary DB and not SQL
    or Access. I'm restricted to just use the ODBC provider issued with the
    application. I created a system DSN with it's provider (usually works
    well with Access and SQL) called "mas". When the page loads, I just get
    the html table field names at the top, but no data. Any help
    appreciated. Code example:

    <HTML>
    <%
    function FixString(InString)
    if instr(InString,"%20")<1 then
    FixString=InString
    Exit Function
    end if
    FixString = replace(InString,"%20"," ")
    end function
    %>
    <title>Test Lookup</title>
    <br>
    The following is example using data from the Inventory Masterfile.
    <br>
    <table border="10" cellpadding="4" cellspacing="1" width="598"
    bordercolorlight="#000080">
    <td width="100" align="center"><font face="Arial"><font size="1"><B>Item
    Number</B></font></font></td>
    <td align="center"><font face="Arial"><font size="1"><B>Item
    Description</B></font></font></td>
    <td align="center"><font face="Arial"><font size="1"><B>Qty On
    Hand</B></font></font></td>
    <td align="center"><font face="Arial"><font size="1"><B>Avg
    Cost</B></font></font></td>
    <td align="center"><font face="Arial"><font size="1"><B>Def
    Warehouse</B></font></font></td>
    </tr>
    <%
    dim strConnectionString
    dim connection
    dim RS
    dim strSQL
    dim query
    query = FixString(request.servervariables("QUERY_STRING"))
    strConnectionString = "mas"
    Set connection = Server.CreateObject("ADODB.Connection")
    connection.Open strConnectionString
    Set RS = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM IM1_InventoryMasterfile WHERE ItemNumber ='" &
    query & "'"
    RS.Open strSQL, connection
    While NOT RS.EOF
    %>
    <td align="center"><font face="Arial"><%=RS("ItemNumber")%></font></td>
    <td align="center"><font
    face="Arial"><%=RS("ItemDescription")%></font></td>
    <td align="center"><font face="Arial"><font
    size="2"><%=RS("TotalQtyOnHand")%></font></font></td>
    <td align="center"><font face="Arial"><font
    size="2"><%=RS("AveCost")%></font></font></td>
    <td align="center"><font face="Arial"><font
    size="2"><%=RS("DefaultWhse")%></font></font></td>
    </tr>
    <%
    RS.MoveNext
    Wend
    RS.Close
    set RS= nothing
    connection.close
    set connection= nothing
    %>
    </HTML>

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Frank Py Guest

  2. Similar Questions and Discussions

    1. create ODBC connection in CF?
      Is there a way to create ODBC DSNs via code? Even if I have to execute something in another language...
    2. Providex ODBC Connection
      Can someone help me with connecting to a Providex odbc connection? Coldfusion shows that it connects successful but when I try to make a Query it...
    3. ODBC Connection
      I created dynamicxls in system DSN to connect to another server J: it showed J:/weekly/suspenselist.xls then I created Data source in...
    4. ODBC Connection Problems CFMX 7
      We are at the beginning stages of upgrading our servers from ColdFusion 5 to CFMX 7. We are running Windows 2000 and IIS with all patches and...
    5. ODBC Connection to Informix 7.2SE on SCO 5.0
      I have a client that is migrating to MSSQL from Informix. I downloaded the client SDK from IBM's website but have not been able to connect to the...
  3. #2

    Default Re: ODBC Connection Problems

    Also, you may want to look into the server.urlencode and server.htmlencode
    functions instead of using your "FixString" function. You should be able to
    avoid all of that.

    Ray at work

    "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    news:OfRT3YKTDHA.2248@TK2MSFTNGP11.phx.gbl...
    > > strSQL = "SELECT * FROM IM1_InventoryMasterfile WHERE ItemNumber ='" &
    > > query & "'"
    >
    > Is itemnumber numeric? If so, remove the single quotes. Also,
    > response.write strSQL to see if it actually contains a number, and run
    > *that* query directly against your "proprietary database" to make sure
    it's
    > returning the results you expect.
    >
    >

    Ray at Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139