Αρχή :: Ενότητες :: Scripting :: Απαντήσεις     
 

Forum

ASP-SQL SERVER-INTRANET - Από {noni}

ΕΙΜΑΙ ΣΕ ΕΝΑ ΤΟΠΙΚΟ ΔΙΚΤΥΟ.
Ο SERVER ΕΧΕΙ ΤΟ ΟΝΟΜΑ JOHΝ.

1. ΕΧΩ ΜΙΑ ΒΑΣΗ ΣΕ SQL SERVER ΠΩΣ ΚΑΝΩ ΤΗΝ ΣΥΝΔΕΣΗ ΣΕ ASP ΧΩΡΙΣ DNS?

2. Η ΒΑΣΗ ΜΠΟΡΕΙ ΝΑ ΒΡΙΣΚΕΤΑΙ ΟΠΟΥ ΘΕΛV Η ΠΡΕΠΕΙ ΝΑ ΕΙΝΑΙ ΣΤΟΝ ΦΑΚΕΛΟ C:\Inetpub\wwwroot?

3. ΕΓΩ ΤΙ ΔΙΕΥΘΥΝΣΗ ΠΡΕΠΕΙ ΝΑ ΓΡΑΨΩ ΣΤΟΝ BROWSER ΚΑΙ ΝΑ ΒΛΕΠΩ ΤΙΣ ASP ΣΕΛΙΔΕΣ

 


Απάντηση από:Alex

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

Απάντηση από:noni

ΕΓΩ ΤΙ ΔΙΕΥΘΥΝΣΗ ΠΡΕΠΕΙ ΝΑ ΓΡΑΨΩ ΣΤΟΝ BROWSER ΚΑΙ ΝΑ ΒΛΕΠΩ ΤΙΣ ASP ΣΕΛΙΔΕΣ ΑΠΟ ΤΟΝ SERVER?

Απάντηση από:Alex

http://localhost και http://127.0.0.1

Απάντηση από:noni

ΤΟ ΑΡΧΕΙΟ 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>&nbsp;</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>&nbsp;</td>
<td><span class="new">
<% Response.Write x_cID %>
</span>&nbsp;</td>
<td><span class="new">
</span>&nbsp;</td>
<td><span class="new">
</span>&nbsp;</td>
<td><span class="new">
</span>&nbsp;</td>
<td><span class="new">
</span>&nbsp;</td>
<td><span class="new">
</span>&nbsp;</td>
<td><span class="new">
</span>&nbsp;</td>
<td><span class="new">
</span>&nbsp;</td>
<td><span class="new">
</span>&nbsp;</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>


ΚΑΤΙ ΔΕΝ ΠΑΕΙ ΚΑΛΑ.

ΟΥΤΕ ΚΑΝ ΜΥΝΗΜΑ ΛΑΘΟΥΣ ΒΓΑΖΕΙ

Απάντηση από:Alex

Το 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

   Πίσω στην προηγούμενη σελίδα






Η Εταιρία | Web Hosting | Domain names | Web Information | Υπηρεσίες | Resellers | Υποστήριξη |
Copyright © 2007–09 4GR.NETWORKS, All rights reserved.