Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mcramsey
Starting Member
4 Posts |
Posted - 2010-03-05 : 04:10:19
|
Hi.How to configure this in order to use the .udl & connection stringsuccessfully?An example of the error:quote: 'The page cannot be displayed'Error Type:Microsoft OLE DB Provider for ODBC Drivers (0x80004005)[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified/trains/Main.asp, line 106
Planning to use .udl with connection string.Don't know where to put it on this 'Main.asp'.The coding of one of the ASP file; Main.asp.I highlighted the error line; line 106.quote: <%@ Language=VBScript %><%Response.Buffer = TrueResponse.Expires = -1000%><HTML><HEAD><TITLE>Main Page</TITLE><base target="_self"><BODY bgProperties=fixed bgColor=#FFFFFF leftMargin=0 topMargin=0 bottommargin10><BR><BR><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;}[bad html removed]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><br><div align="center"><div CLASS="para1" align="center" style="width: 661; height: 80"> <p style="text-align: center">News Flash</p></div> <div CLASS="para2" align="center" style="width: 658; height: 80"> <p style="text-align: center">News Flash</p></div> </div><p align="justify"> </p><p align="justify"> </p><p align="justify"> </p><%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><br><br><% Response.Write "<b>There's no news to publish.</b>" %></center><% else Call DrawPage() End if%></center><p> </p><P><P><p align="center"> </p><p align="center"> </p><p align="center"><font face="Webdings" color="#CC99FF" size="7"><marquee scrollamount="3">CDBFGHKSPITJQ</marquee></font></p></BODY></HTML>
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2010-03-08 : 06:43:31
|
This is a classic ASP question.There are two ways of doing it CORRECTLY1. Either set your connection string as a global variable in your global.asa file2. set the connection string in a seperate file in the classic ASP file and call it with a server side include file.both ways your connection string is centralized.Also for neater programming code, keep your server side script blocks on top.best wishes |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2010-03-08 : 06:45:20
|
Also you cant use a DSN in classic ASP, see this for your connection stringshttp://connectionstrings.com/ |
|
|
jet1337
Starting Member
11 Posts |
Posted - 2010-03-16 : 03:12:15
|
thanks afrikaASPnix.com |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2010-03-18 : 10:21:48
|
:) |
|
|
|
|
|
|
|