March 18, 2010 at 6:53 pm
Hi.
Windows XP SP3
SQL Server 2008
Login:sa
Password:12345
My ODBC, am I doing it right?
The error;
The coding in 'Main.asp' file.
Line 106 is the bold text.
<%@ Language=VBScript %>
<%
Response.Buffer = True
Response.Expires = -1000
%>
<HTML><HEAD><TITLE>Main Page</TITLE>
<base target="_self">
<BODY bgProperties=fixed bgColor=#FFFFFF leftMargin=0 topMargin=0 bottommargin10>
<DIV style="LEFT: 5px; POSITION: absolute; TOP: 80px"></DIV>
<style type="text/css">
body {font-size: 8pt; font-family: verdana; color:white;}
table, tr, td {font-size: 10pt; font-family: verdana; color: black;}
a:link {font-size: 8pt; font-family: verdana; color:black; text-decoration: none;}
a:visited {font-size: 8pt; font-family: verdana; color:black; text-decoration: none;}
a:active {font-size: 8pt; font-family: verdana; color:#CCCCFF; text-decoration: none;}
a:hover {font-size: 8pt; font-family: verdana; color: #db7093; text-decoration: none;}
<!--A:hover{color:#db7093;text-decoration:underline; cursor:help}-->
font {font-size: 8pt; font-family: arial}
.para1 {position:absolute; top: 48; left: 106; font-family: "font2, Georgia"; font-size: 50px; font-weight:bold; line-height: 40px; text-align: left; color: #CC99FF; }
.para2 {position:absolute; top: 46; left: 105; font-family: "font1, Georgia"; font-size: 50px; font-weight:bold; line-height: 40px; text-align: left; color: #660066; }
.badan1 {font-family: "Verdana"; font-size: 10pt; font-weight:bold; text-align: left; color: #FFFFFF; }
.badan2 {font-family: "Verdana"; font-size: 10pt; font-weight:bold; text-align: left; color: #000000; }
.edit {font-size: 10pt; font-family: symbol; color: #ff1493;}
</style>
<! SCROLLBAR COLOR !>
<STYLE type=text/css>BODY {
SCROLLBAR-FACE-COLOR: #CC99FF; FONT-SIZE: 8pt;
SCROLLBAR-HIGHLIGHT-COLOR: #990099;
SCROLLBAR-SHADOW-COLOR: #CC66FF; COLOR: #000000;
SCROLLBAR-3DLIGHT-COLOR: #9900ff;
SCROLLBAR-ARROW-COLOR: #993366;
SCROLLBAR-TRACK-COLOR:#CC99FF; FONT-FAMILY: arial, trebuchet MS, verdana, arial, sans-serif;
SCROLLBAR-DARKSHADOW-COLOR: #000000
}
</STYLE>
</HEAD>
<div align="center"><div CLASS="para1" align="center" style="width: 661; height: 80">
<p style="text-align: center">News Flash</div>
<div CLASS="para2" align="center" style="width: 658; height: 80">
<p style="text-align: center">News Flash</div>
</div>
<p align="justify"><p align="justify"><p align="justify">
<%
Sub DrawPage()
%><center>
<div align="center">
<%
'Set the current record pointer to the first record of the recordset
rs.MoveFirst
'Loop through all the records in the recordset
while not rs.EOF
'Load recordset field values into local variables
Title = rs("News_title") & ""
Body = rs("News_body") & ""
DateTime = rs("News_Date") & ""
%>
<table width="790" border="0" height="48" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0"
cellspacing="0" align=center>
<tr>
<td width="104" height="21" bgcolor="#660066" style="font-size: 10pt; font-family: verdana; color: white"></td>
<td width="1625" height="21" bgcolor="#660066"><div CLASS="badan1"><%=Title %></div></td>
<td height="21" bgcolor="#660066" width="162"><div CLASS="badan1"><%=DateTime %></div></td>
</tr>
<tr>
<td width="104" height="12" bgcolor="#CC99FF" style="font-size: 10pt; font-family: verdana; color: black"></td>
<td width="1787" height="12" bgcolor="#CC99FF" style="font-size: 10pt; font-family: verdana; color: black" colspan="2">
<div CLASS="badan2" style="width: 705; height: 13"><%=Body %></div></div></td>
</tr>
<tr>
<td width="1891" bgcolor="#CC99FF" style="font-size: 4pt; font-family: verdana; color: black" colspan="3" height="9"></td>
</tr>
<tr>
<td width="2011" height="6" colspan="3" style="font-size: 10pt; font-family: verdana; color: black">
<p align="center">
</td>
</tr>
</table>
<%
rs.MoveNext
wend
%>
<%
End Sub
'Database coding commence
dim rs, sql, cn, Title, Body, DateTime
'Set connection details
set cn = server.CreateObject("ADODB.Connection")
cn.Open "DSN=Trains;UID=sa;PWD=;DATABASE=Trains"
'Set sql string
sql = "SELECT * FROM News where News_Expiry >"
sql = sql & "'" & TRIM(Date()) & "'"
sql = sql & " order by news_id desc"
'Create a recordset
set rs = cn.Execute(sql)
if rs.EOF then
%>
<center>
<IMG SRC=images/tanda.gif>
<%
Response.Write "<b>There's no news to publish.</b>"
%>
</center>
<%
else
Call DrawPage()
End if
%>
</center>
<p align="center">
<p align="center">
<p align="center"><font face="Webdings" color="#CC99FF" size="7">
<marquee scrollamount="3">CDBFGHKSPITJQ</marquee></font>
</BODY>
</HTML>
March 19, 2010 at 4:21 am
Why are you using the SA Account in your .NET Code? You are asking for trouble...
Why are you using a DSN Connection?
I'm sure that you could find numerous examples; on the web as how to accomplish what you are doing but I would stay away from using the SA Account and a DSN Connection.
WC
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply