Ask a Question related to ASP Database, Design and Development.
-
Frank Py #1
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
-
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... -
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... -
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... -
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... -
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... -
Ray at #2
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...it's>> > 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> returning the results you expect.
>
>
Ray at Guest



Reply With Quote

