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-04 : 11:29:51
|
Hi.Saw these links 'http://www.connectionstrings.com/' and 'http://www.carlprothman.net/Default.aspx?tabid=81' on this thread;http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=87086Where should I put the connection string on my troubled asp file; 'main.asp'?I wrote it with VBScript.The web page loaded with IIS but got some errors. Line 106 refers to the bold blue color line.The error;quote: 'The page cannot be displayed'Technical Information (for support personnel)Error Type:Microsoft OLE DB Provider for ODBC Drivers (0x80004005)[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified/train/main.asp, line 106
The 'Main.asp' file;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 recordsetrs.MoveFirst'Loop through all the records in the recordsetwhile not rs.EOF'Load recordset field values into local variablesTitle = 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.MoveNextwend%><%End Sub'Database coding commencedim rs, sql, cn, Title, Body, DateTime'Set connection detailsset cn = server.CreateObject("ADODB.Connection")cn.Open "DSN=Trains;UID=sa;PWD=;DATABASE=Trains"'Set sql stringsql = "SELECT * FROM News where News_Expiry >"sql = sql & "'" & TRIM(Date()) & "'"sql = sql & " order by news_id desc"'Create a recordsetset 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><%elseCall 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>
|
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-03-04 : 11:39:17
|
Here is one way...Dim connStr As StringconnStr = "Your connection string here"Dim connection As SqlConnection = New SqlConnection(connStr)connection.Open() its better you set the connection string in your web.config and access it in ur code. |
 |
|
|
mcramsey
Starting Member
4 Posts |
Posted - 2010-03-04 : 17:05:40
|
| Where can I find the web.config file? |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-03-04 : 17:21:46
|
| there isn't one...you're using ASP Classic.can use udl though...or even put it in an include file.see these:http://msdn.microsoft.com/en-us/library/e38h511e(VS.71).aspxhttp://msdn.microsoft.com/en-us/library/5yf2h92c(VS.71).aspx |
 |
|
|
mcramsey
Starting Member
4 Posts |
Posted - 2010-03-04 : 19:35:56
|
Ok.I installed it.What should I fill in these?I have 'Microsoft SQL Server 2008 Express' installed. Yeah...the online system belongs to my sis, back in 2003.Her final year project.Is there any other way to make the system work besides using IIS? |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-03-05 : 08:50:22
|
| in the connection tab, type in the server name (or server\instance if it's a named instance)choose windows nt security, or key in specific username and pwd.initial catalog should be the database you want to connect to (Trains). It will appear in the drop-down menu if u did the first 2 steps right and have permissions setup.That's it.Without IIS...why? Can't make web pages work without a web server...there are tools to make ASP run on Apache, but I wouldn't do that. |
 |
|
|
|
|
|
|
|