Jedi 22 Report post Posted March 19, 2010 (Salam) SQL Server 2008 Login:sa Password:12345 [img]http://img2.pict.com/9d/b2/65/3153366/0/sql.jpg[/img] ODBC - Betul ke ni? [img]http://img2.pict.com/ee/6b/8b/3153363/0/800/odbc.jpg[/img] Tapi masih kuar error; [img]http://img2.pict.com/cd/8e/ad/3153435/0/800/ptb.jpg[/img] Coding error line 106 tu; [quote]<%@ 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") [b][i]cn.Open "DSN=Trains;UID=sa;PWD=;DATABASE=Trains"[/i][/b] '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>[/quote] Share this post Link to post Share on other sites
DevGuy 0 Report post Posted March 20, 2010 ko kena select dataabse ko dulu.by default dia kaan amik database master.make sure select database tu Share this post Link to post Share on other sites
Jedi 22 Report post Posted March 23, 2010 Dalam ODBC cuma ada 4; [img]http://img2.pict.com/8b/81/bd/3195714/0/odbc2.jpg[/img] Aku pilih 'master' Dalam SQL Server 2008 memang ada 'master'; [img]http://img2.pict.com/c1/98/a0/3195719/0/sql.gif[/img] Rasanya dah connect kot ODBC ngan SQL Server tu. Tapi masih ada error; cn.Open "DSN=Trains;UID=sa;[b]PWD=[/b];DATABASE=Trains" [i] Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D) [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'sa'. /Trains/Main.asp, line 106[/i] Kalau; cn.Open "DSN=Trains;UID=sa;PWD=[b]12345[/b];DATABASE=Trains" [i] Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D) [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database "Trains" requested by the login. The login failed. /Trains/Main.asp, line 106[/i] 'Trains' ni fail sql. Perlu ke masukkan dan connect dalam SQL Server 2008 tu? Kena connect dengan 'master' ke? [img]http://img2.pict.com/a7/15/17/3195713/0/sql2.jpg[/img] Share this post Link to post Share on other sites