all groups > inetserver asp db > july 2003 >
You're in the

inetserver asp db

group:

Using an asp page to return a sql query


Using an asp page to return a sql query cswartz NO[at]SPAM stromberg.com
7/31/2003 10:05:43 AM
inetserver asp db: I know that there must be a way to do this, but in my limited
knowledge I am stuck.

I am using 2 tables
1. "BTstatus"
BugIndex
Date Entered
Company
Technician
Developer
PROGRAM
Status
PRIORITY

2."noc"
Bugindex
# of calls
Description

Bug index is the common key

I would like to display the first table and when you click on the
Bugindex it would display like a select * from noc where bugindex ='?'
?= the bugindex #

To go along with this on the new screen I would like to be able to
update the # of calls for that particular bugindex. There are a ton of
things out that that are sorta like this but nothing specifically.

Re: Using an asp page to return a sql query SPA
7/31/2003 5:03:23 PM
OK I am assuming you know how to connect to your database and retrieve =
recordsets for the 2 tables you have mentioned.

Lets the connection object is objConn, the recordsets rsBTStatus and =
rsNOC.

Your main asp page should have the following code:

<%
:
:
<Database connection code>
:
%>
<Table width=3D"100%">
<TR> =20
<TH>BugIndex</TH>
<TH>Date Entered</TH>
<TH>Company</TH>
<TH>Technician</TH>
<TH>Developer</TH>
<TH>PROGRAM</TH>
<TH>Status</TH>
<TH>PRIORITY</TH>
</TR>
<% =20
While not rsBTStatus.EOF
%>
<TR>
<TD>
<A =
HREF=3D'NOC.ASP?Bindex=3D<%=3DrsBTStatus.Fields(0)%>'><%=3DrsBTStatus.Fie=
lds(0)%></A>
</TD>
<TD><%=3DrsBTStatus.Fields(1)%></TD> =20
<TD><%=3DrsBTStatus.Fields(2)%></TD> =20
<TD><%=3DrsBTStatus.Fields(3)%></TD>
<TD><%=3DrsBTStatus.Fields(4)%></TD>
<TD><%=3DrsBTStatus.Fields(5)%></TD>
<TD><%=3DrsBTStatus.Fields(6)%></TD>
<TD><%=3DrsBTStatus.Fields(7)%></TD>
</TR>
<%
rsBTStatus.MoveNext()
Wend
%>
:
:
<Close recrordsets and connection>



Now your NOC.asp page should contain the following code:

<%
:
:
Dim strBugIndex
Dim strSql

strBugIndex =3D trim(Request.QueryString("Bindex"))
:
<Database connection code>
:
strSql =3D "Select * from NOC where BugIndex=3D ' " & strBugIndex & " ' =
=20
(Note: Theres no space between the single and double quotes)

rsNOC.Open strSql, objConn
%>
<Table width=3D"100%">
<TR> =20
<TH>BugIndex</TH>
<TH># of calls</TH>
<TH>Description</TH>
</TR>
<% =20
While not rsNOC.EOF
%>
<TR>
<TD><%=3DrsNOC.Fields(1)%></TD> =20
<TD><%=3DrsNOC.Fields(2)%></TD> =20
<TD><%=3DrsNOC.Fields(3)%></TD>
</TR>
<%
rsNOC.MoveNext()
Wend
%>
:
:
<Close recrordsets and connection>


Havent tested the above code .. but hope you got the idea now .. =
clicking on the BugIndex link on the first page will open a new window =
with the NOC table listing records having the BugIndex that you clicked.

HTH

SPA


[quoted text, click to view]
Re: Using an asp page to return a sql query The Chad
8/1/2003 4:53:22 PM

I am assuming this would be an acceptable connection statement?
<%

Dim conn

Set conn = Server.CreateObject("ADODB.Connection")

conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog =
techsupportBT; User Id = sa; Password="

If conn.errors.count = 0 Then

Response.Write "Connected OK"

End If

%>
IIS and SQL are on the same box


*** Sent via Developersdex http://www.developersdex.com ***
Re: Using an asp page to return a sql query Bob Barrows
8/1/2003 8:45:47 PM
[quoted text, click to view]
No, this is not acceptable: the sa account should never be used by an
application (hopefully you don't really have a blank password for the sa
account ... )

Otherwise, it looks ok.

Bob Barrows

Re: Using an asp page to return a sql query The Chad
8/2/2003 5:03:35 AM


I am just using it for an intranet web page as more of a managment tool,
so I didn't figure security was that big of an issue for the situation.
Thank you for all of your help.

*** Sent via Developersdex http://www.developersdex.com ***
Re: Using an asp page to return a sql query Bob Barrows
8/2/2003 8:10:26 AM
[quoted text, click to view]


Many companies are hacked by their own employees. And Slammer worked partly
because no passwords had been assigned to sa on the infected machines...

But it's only a job ... you can always get another one ...

Bob

AddThis Social Bookmark Button