Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP Newbie 2

Status
Not open for further replies.

DANZIG

Technical User
Mar 8, 2001
142
US
Hello,

I'm writing my first ASP page that uses a SQL 2000 DB on the backend and am having a few problems with it. I know I must be doing something wrong.

I'm connecting to a server with the information below.

Server Name: SQLITSERVER
Database Name: ITDB
Table Name:Workstation_Bios_Information


The asp that I've wrote to use is this:

<html>
<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 4.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<title>Workstation Bios Information</title>
</head>

<body>
<p align=&quot;center&quot;><img border=&quot;0&quot; src=&quot;images/logo-small.gif&quot;></p>
<p align=&quot;center&quot;><b><font size=&quot;5&quot; face=&quot;Arial&quot;>Workstation Bios
Information</font></b></p>
<div align=&quot;center&quot;>
<center>
<TABLE borderColor=#000000 cellSpacing=0 cellPadding=2 border=1>
<TBODY>
<TR style=&quot;BACKGROUND: #009FD7; COLOR: white&quot; bgColor=#009FD7>
<TD width=&quot;148&quot; valign=&quot;middle&quot; align=&quot;center&quot; bgcolor=&quot;#009FD7&quot;><font face=&quot;Arial&quot;><i>System
Name</i></font> </TD>
<TD width=&quot;148&quot; valign=&quot;middle&quot; align=&quot;center&quot; bgcolor=&quot;#009FD7&quot;><font face=&quot;Arial&quot;><i>System
Manufacturer</i></font> </TD>
<TD width=&quot;148&quot; valign=&quot;middle&quot; align=&quot;center&quot; bgcolor=&quot;#009FD7&quot;><font face=&quot;Arial&quot;><i>System
Model</i></font> </TD>
<TD width=&quot;149&quot; valign=&quot;middle&quot; align=&quot;center&quot; bgcolor=&quot;#009FD7&quot;><font face=&quot;Arial&quot;><i>System
Serial Number</i></font> </TD>
<TD width=&quot;149&quot; valign=&quot;middle&quot; align=&quot;center&quot; bgcolor=&quot;#009FD7&quot;><font face=&quot;Arial&quot;><i>System
Bios Revision</i></font> </TD>
<TD width=&quot;149&quot; valign=&quot;middle&quot; align=&quot;center&quot; bgcolor=&quot;#009FD7&quot;><font face=&quot;Arial&quot;><i>System
Bios Version</i></font> </TD>
<TD width=&quot;149&quot; valign=&quot;middle&quot; align=&quot;center&quot; bgcolor=&quot;#009FD7&quot;><font face=&quot;Arial&quot;><i>Collection
Date</i></font> </TD>
</TR>


<%
dim oRsSWBI
Set oRsSWBI=Server.CreateObject(&quot;ADODB.Connection&quot;)
oRsSWBI.Open &quot;driver=SQL Server;server=ITSQLSERVER;uid=ITUSER;pwd=ITPASSWORD;database=ITDB;&quot;
Set oRsSWBITbl=oRsSWBI.Execute(&quot;SELECT * FROM Workstation_Bios_Information&quot;)
oRsSWBITbl.Sort = SystemName
Do While Not oRsSWBITbl.EOF
TblIdx = TblIdx+1
If TblIdx = 1 Then
TrClr = &quot;#cccccc&quot;
End If
If TblIdx = 2 Then
TrClr = &quot;#ffffff&quot;
End If
Response.Write &quot;<TR bgColor=&quot;&TrClr&&quot;>&quot;
Response.Write &quot; <TD width=&quot;&chr(34)&&quot;148&quot;&chr(34)&&quot; align=&quot;&chr(34)&&quot;center&quot;&chr(34)&&quot;><font face=&quot;&chr(34)&&quot;Arial&quot;&chr(34)&&quot;>&quot;&oRsSWBITbl(&quot;SystemName&quot;)&&quot;</font></TD>&quot;
Response.Write &quot; <TD width=&quot;&chr(34)&&quot;148&quot;&chr(34)&&quot; align=&quot;&chr(34)&&quot;center&quot;&chr(34)&&quot;><font face=&quot;&chr(34)&&quot;Arial&quot;&chr(34)&&quot;>&quot;&oRsSWBITbl(&quot;SystemManufacturer&quot;)&&quot;</font></TD>&quot;
Response.Write &quot; <TD width=&quot;&chr(34)&&quot;148&quot;&chr(34)&&quot; align=&quot;&chr(34)&&quot;center&quot;&chr(34)&&quot;><font face=&quot;&chr(34)&&quot;Arial&quot;&chr(34)&&quot;>&quot;&oRsSWBITbl(&quot;SystemModel&quot;)&&quot;</font></TD>&quot;
Response.Write &quot; <TD width=&quot;&chr(34)&&quot;148&quot;&chr(34)&&quot; align=&quot;&chr(34)&&quot;center&quot;&chr(34)&&quot;><font face=&quot;&chr(34)&&quot;Arial&quot;&chr(34)&&quot;>&quot;&oRsSWBITbl(&quot;SystemSerialNumber&quot;)&&quot;</font></TD>&quot;
Response.Write &quot; <TD width=&quot;&chr(34)&&quot;148&quot;&chr(34)&&quot; align=&quot;&chr(34)&&quot;center&quot;&chr(34)&&quot;><font face=&quot;&chr(34)&&quot;Arial&quot;&chr(34)&&quot;>&quot;&oRsSWBITbl(&quot;SystemBiosRevision&quot;)&&quot;</font></TD>&quot;
Response.Write &quot; <TD width=&quot;&chr(34)&&quot;148&quot;&chr(34)&&quot; align=&quot;&chr(34)&&quot;center&quot;&chr(34)&&quot;><font face=&quot;&chr(34)&&quot;Arial&quot;&chr(34)&&quot;>&quot;&oRsSWBITbl(&quot;SystemBiosVersion&quot;)&&quot;</font></TD>&quot;
Response.Write &quot; <TD width=&quot;&chr(34)&&quot;148&quot;&chr(34)&&quot; align=&quot;&chr(34)&&quot;center&quot;&chr(34)&&quot;><font face=&quot;&chr(34)&&quot;Arial&quot;&chr(34)&&quot;>&quot;&oRsSWBITbl(&quot;CollectionDate&quot;)&&quot;</font></TD>&quot;
Response.Write &quot;</TR>&quot;
If TblIdx = 2 Then
TblIdx = 0
End If
Loop
%>


</table>
</center>
</div>
</body>
</html>


All it seems to do is spike the processor on the server and return &quot;Page Can Not Be Displayed&quot; script.timeout error.

Any help in writing this correctly to have as an example to work from would be appreciated.
 
Danzig,

Place the following above the Loop statement.

oRsSWBITbl.MoveNext


Rob
 
That worked 8)

My sort doesn't seem to be working though.


oRsSWBITbl.Sort = SystemName


Any ideas on that?

Thanks in advance.
 
Danzig,

In your SQL statement, you could try this instead:

&quot;SELECT * FROM Workstation_Bios_Information SORT BY Workstation ASC&quot;

Or put DESC depending on the order you wish for them to be sorted.


Rob
 
Danzig,

Oops, also take out

oRsSWBITbl.Sort = SystemName

if you change your SQL statement.


Rob
 
Danzig,

It's been a long day - I meant to put SystemName where I put Workstation.


Sorry,

Rob
 
I've seen many sql statements use &quot;ORDER BY&quot; as opposed to your suggested &quot;Sort By&quot; are they interchangeable?

Earnie Eng
 
Nope, you are right, my mind is going one way and the fingers on the keyboard are going the other way. Thanks for correcting me ahmun.


Rob
 
Ya'll rock!
Giving both of ya stars.

one last question...
if the field returns a null value it breaks the cell borders on that row in the asp. Is there an easy way to correct that?
 
a stoopid solution...
as well as the value you are adding from the database, insert a space? (&nbsp) or just simply put a space in your code:
Code:
<TD><%=something%> </TD>
   or
<TD><%=something%>&nbsp</TD>

or in your case since you are using response.write... simply put the ' ' or '&nbsp' in the corresponding location

Earnie Eng
 
Danzig,

You have to put in a conditional, something like this:

If oRsSWBITbl(&quot;SomeField&quot;) = &quot;&quot; Then
Response.Write &quot;<td>&bnsp;</td>&quot; & vbCrLf
Else
Response.Write &quot;<td>&quot; & oRsSWBITbl(&quot;SomeField&quot;) & &quot;</td>&quot; & vbCrLf
End If


Hope this helps,

Rob
 
Ok time for me to go home.

it should be nbsp, not bnsp


Rob
 
haha... time for me to go home, too...

Code:
<TD><%=something%> </TD>
   or
<TD><%=something%>
&
Code:
nbsp
Code:
</TD>

or is it... that TGML processes &
Code:
nbsp
as a space instead of the literal characters that I intended


Earnie Eng
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top