ΕΙΜΑΙ ΣΕ ΕΝΑ ΤΟΠΙΚΟ ΔΙΚΤΥΟ.
Ο SERVER ΕΧΕΙ ΤΟ ΟΝΟΜΑ JOHΝ.
1. ΕΧΩ ΜΙΑ ΒΑΣΗ ΣΕ SQL SERVER ΠΩΣ ΚΑΝΩ ΤΗΝ ΣΥΝΔΕΣΗ ΣΕ ASP ΧΩΡΙΣ DNS?
2. Η ΒΑΣΗ ΜΠΟΡΕΙ ΝΑ ΒΡΙΣΚΕΤΑΙ ΟΠΟΥ ΘΕΛV Η ΠΡΕΠΕΙ ΝΑ ΕΙΝΑΙ ΣΤΟΝ ΦΑΚΕΛΟ C:\Inetpub\wwwroot?
3. ΕΓΩ ΤΙ ΔΙΕΥΘΥΝΣΗ ΠΡΕΠΕΙ ΝΑ ΓΡΑΨΩ ΣΤΟΝ BROWSER ΚΑΙ ΝΑ ΒΛΕΠΩ ΤΙΣ ASP ΣΕΛΙΔΕΣ
1) <%
DSN1 = "DRIVER={SQL Server};SERVER=servername;UID=username;PWD=password;"
DSN1 = DSN1 & "DATABASE=databasename"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open DSN1
%>
2) Η βάση θα βρίσκετε στον SQL server
3) http://localhost
ΕΓΩ ΤΙ ΔΙΕΥΘΥΝΣΗ ΠΡΕΠΕΙ ΝΑ ΓΡΑΨΩ ΣΤΟΝ BROWSER ΚΑΙ ΝΑ ΒΛΕΠΩ ΤΙΣ ASP ΣΕΛΙΔΕΣ ΑΠΟ ΤΟΝ SERVER?
http://localhost και http://127.0.0.1
ΤΟ ΑΡΧΕΙΟ CONNECTION.ASP ΕΧΕΙ ΤΟΝ ΕΞΗΣ ΚΩΔΙΚΑ
<%
Dim strSQLServerName 'Holds the name of the SQL Server
Dim strSQLDBUserName 'Holds the user name (for SQL Server Authentication)
Dim strSQLDBPassword 'Holds the password (for SQL Server Authentication)
Dim strSQLDBName 'Holds name of a database on the server
'Enter the details of your SQL server below
strSQLServerName = "SYBERIA" 'Holds the name of the SQL Server
strSQLDBUserName = "aa" 'Holds the user name (for SQL Server Authentication)
strSQLDBPassword = "x" 'Holds the password (for SQL Server Authentication)
strSQLDBName = "ora8i" 'Holds name of a database on the server
strCon = "Provider=SQLOLEDB;Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
%>
ΤΟ ΑΡΧΕΙΟ CUSTOMERS ΕΧΕΙ ΤΟΝ ΕΞΗΣ ΚΩΔΙΚΑ
<!--#include file="connection.asp"-->
<%
displayRecs = 12
recRange = 10
%>
<%
'Create database connection
'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set the connection string to the database
adoCon.connectionstring = strCon
'Set an active connection to the Connection object
adoCon.Open
' Build SQL
strsql = "SELECT * FROM F620"
'Response.Write strsql
Set rs = Server.CreateObject("ADODB.Recordset")
rs.cursorlocation = 3
rs.Open strsql, conn, 1, 2
totalRecs = rs.RecordCount
' Check for a START parameter
If Request.QueryString("start").Count > 0 Then
startRec = Request.QueryString("start")
Session("Customers_REC") = startRec
ElseIf Request.QueryString("pageno").Count > 0 Then
pageno = Request.QueryString("pageno")
If IsNumeric(pageno) Then
startRec = (pageno-1)*displayRecs+1
If startRec <= 0 Then
startRec = 1
ElseIf startRec >= ((totalRecs-1)\displayRecs)*displayRecs+1 Then
startRec = ((totalRecs-1)\displayRecs)*displayRecs+1
End If
Session("Customers_REC") = startRec
Else
startRec = Session("Customers_REC")
If Not IsNumeric(startRec) Or startRec = "" Then
startRec = 1 ' Reset start record counter
Session("Customers_REC") = startRec
End If
End If
Else
startRec = Session("Customers_REC")
If Not IsNumeric(startRec) Or startRec = "" Then
startRec = 1 'Reset start record counter
Session("Customers_REC") = startRec
End If
End If
%>
<p> </p>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td><span class="new"><a href="Customersadd.asp">Add</a></span></td>
</tr>
</table>
<p>
<form method="post">
<table border="0" cellspacing="1" cellpadding="4" bgcolor="#CCCCCC">
<%
' Avoid starting record > total records
If CLng(startRec) > CLng(totalRecs) Then
startRec = totalRecs
End If
' Set the last record to display
stopRec = startRec + displayRecs - 1
' Move to first record directly for performance reason
recCount = startRec - 1
If Not rs.Eof Then
rs.MoveFirst
rs.Move startRec - 1
End If
recActual = 0
Do While (Not rs.Eof) And (recCount < stopRec)
recCount = recCount + 1
If CLng(recCount) >= CLng(startRec) Then
recActual = recActual + 1 %>
<%
' Set row color
bgcolor = "#FFFFFF"
%>
<%
' Display alternate color for rows
If recCount Mod 2 <> 0 Then
bgcolor = "#F5F5F5"
End If
%>
<%
' Load Key for record
key = rs("VOU")
x_cID = rs("FLG1")
%>
<tr bgcolor="<%= bgcolor %>">
<td><span class="new">
<% Response.Write key %>
</span> </td>
<td><span class="new">
<% Response.Write x_cID %>
</span> </td>
<td><span class="new">
</span> </td>
<td><span class="new">
</span> </td>
<td><span class="new">
</span> </td>
<td><span class="new">
</span> </td>
<td><span class="new">
</span> </td>
<td><span class="new">
</span> </td>
<td><span class="new">
</span> </td>
<td><span class="new">
</span> </td>
</tr>
<%
End If
rs.MoveNext
Loop
%>
</table>
</form>
<%
' Close recordset and connection
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
%>
<span class="new">
<%
' Display page numbers
If totalRecs > 0 Then
rsEof = (totalRecs < (startRec + displayRecs))
' Find out if there should be Backward or Forward Buttons on the table.
If startRec = 1 Then
isPrev = False
Else
isPrev = True
PrevStart = startRec - displayRecs
If PrevStart < 1 Then PrevStart = 1 %>
<a href="Customerslist.asp?start=<%=PrevStart%>"><b>Prev</b></a>
<%
End If
If (isPrev Or (Not rsEof)) Then
x = 1
y = 1
dx1 = ((startRec-1)\(displayRecs*recRange))*displayRecs*recRange+1
dy1 = ((startRec-1)\(displayRecs*recRange))*recRange+1
If (dx1+displayRecs*recRange-1) > totalRecs Then
dx2 = (totalRecs\displayRecs)*displayRecs+1
dy2 = (totalRecs\displayRecs)+1
Else
dx2 = dx1+displayRecs*recRange-1
dy2 = dy1+recRange-1
End If
While x <= totalRecs
If x >= dx1 And x <= dx2 Then
If CLng(startRec) = CLng(x) Then %>
<b><%=y%></b>
<% Else %>
<a href="Customerslist.asp?start=<%=x%>"><b><%=y%></b></a>
<% End If
x = x + displayRecs
y = y + 1
ElseIf x >= (dx1-displayRecs*recRange) And x <= (dx2+displayRecs*recRange) Then
If x+recRange*displayRecs < totalRecs Then %>
<a href="Customerslist.asp?start=<%=x%>"><b><%=y%>-<%=y+recRange-1%></b></a>
<% Else
ny=(totalRecs-1)\displayRecs+1
If ny = y Then %>
<a href="Customerslist.asp?start=<%=x%>"><b><%=y%></b></a>
<% Else %>
<a href="Customerslist.asp?start=<%=x%>"><b><%=y%>-<%=ny%></b></a>
<% End If
End If
x=x+recRange*displayRecs
y=y+recRange
Else
x=x+recRange*displayRecs
y=y+recRange
End If
Wend
End If
' Next link
If NOT rsEof Then
NextStart = startRec + displayRecs
isMore = True %>
<a href="Customerslist.asp?start=<%=NextStart%>"><b>Next</b></a>
<% Else
isMore = False
End If %>
<br>
<% If CLng(startRec) > CLng(totalRecs) Then startRec = totalRecs
stopRec = startRec + displayRecs - 1
recCount = totalRecs - 1
If rsEOF Then recCount = totalRecs
If stopRec > recCount Then stopRec = recCount %>
Records <%= startRec %> to <%= stopRec %> of <%= totalRecs %>
<% Else %>
No records found
<% End If %>
</body>
</html>
ΚΑΤΙ ΔΕΝ ΠΑΕΙ ΚΑΛΑ.
ΟΥΤΕ ΚΑΝ ΜΥΝΗΜΑ ΛΑΘΟΥΣ ΒΓΑΖΕΙ
Το SYBERIA δεν είναι SQL server name
Θα πρέπει να δώσεις στο
strSQLServerName = "SYBERIA" 'Holds the name of the SQL Server
Ip address του SQL server ή domain name
ΠΧ
strSQLServerName = "254.158.25.14" 'Holds the name of the SQL Server
tip: Αυτό που οι περισσότεροι άνθρωποι θέλουν πραγματικά είναι να τους ακούσει κάποιος , να τους σεβαστεί και να τους καταλάβει . Όταν αντιληφθούν ότι τους καταλαβαίνετε , αποκτούν το κίνητρο για να κατανοήσουν και την δική σας άποψη. * F5 για νέο tip