PDA

View Full Version : cose strane! help!!!


scoppato
28-04-2002, 15:42
Ciao a tutti!
Vengo subito al dunque:
sul mio PC portatile mi sono costruito un'applicazione per una piccola intranet con Dreamweaver ULTRADEV, tutto funziona a meraviglia!
Ho deciso di provarla su una rete LAN di 5 PC, quindi ho copiato letteralmente la cartella del "sito" dal miuo portatile al PC che funge da server. Sul server ho settato la connessione al db (è un db in Access), ho impostato la condivisione web alla cartella che contiene i file. Tutto bene! Provo, tramite IE, a navigare nell'applicazione e le pagine funzionano correttamente, funzionano le varie pagine di ricerca, l'inserimento di dati etc. Ma nel momento in cui carico pagine che visualizzano dati, i quali dipendono da una data, nelle pagine non compaiono i dati che dovrebbero apparire. Mi spiego meglio: se faccio una ricerca per esmpio per nome, i risultati mi vengono visualizzati correttamente, ma se faccio una ricerca per data (in formato gg/mm/yy) non compare nessun dato, come se il campo data del db non contenesse la data inserita! La cosa strana è questa:
- se faccio la stessa cosa sul portatile, tutto funziona;
- nella tabella da cui la pagina asp pesca i dati contiene varie date tra cui quella che voglio cercare.

che succede?
qulcuno mi puo' aiutare?

vi ringrazio anticipatamente!!!

cionci
28-04-2002, 17:39
Confronta fra i vari PC le impostazioni di rappresentazione di data e ora...potrebbe essere lì il problema...

scoppato
28-04-2002, 21:04
è un controllo che ho gia' fatto. ho anchge messo, nella pagina asp
<%
Session.LCID = 1040
%>

ma nulla di fatto!

cionci
29-04-2002, 20:13
Stampa la query che fai al DB...ci sono alcune versioni di windows che hanno problemi nella conversione automatica da variabile di tipo Date a stringa...

scoppato
29-04-2002, 23:24
Questo è il codice che ha generato Dreamweaver ULTRADEV (spero che non ti annoi!! è un po' lungo!! grazie pèer l'interesse!):

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/easycall10.asp" -->
<%
session.LCID = 1040
%>


<%
MyDate = Date
mm = Month(MyDate)
if mm < 10 then
mm = "0" & mm
end if
dd = Day(MyDate)
if dd < 10 then
dd = "0" & dd
end if
yy = Year(MyDate)
session("oggi") = dd & "/" & mm & "/" & yy
%>
<%
Dim lavagna__data
lavagna__data = "%"
if (Session("oggi") <> "") then lavagna__data = Session("oggi")
%>
<%
set lavagna = Server.CreateObject("ADODB.Recordset")
lavagna.ActiveConnection = MM_easycall10_STRING
lavagna.Source = "SELECT NomeUtente, CodiceContatto, COGNOME, DATA_APP, ORA_APP, RagioneSoc, NOMINATIVO, DATA_CON FROM Appuntamenti WHERE DATA_CON LIKE '" + Replace(lavagna__data, "'", "''") + "' AND EsitoTelf = 'Appuntamento' ORDER BY ORA_APP ASC"
lavagna.CursorType = 1
lavagna.CursorLocation = 2
lavagna.LockType = 3
lavagna.Open()
lavagna_numRows = 0
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then MM_removeList = MM_removeList & "&" & MM_paramName & "="
MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
End If
Next

' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth <> "") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL <> "") Then MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm <> "") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<%
' *** Move To Record: set the strings for the first, last, next, and previous links

MM_keepMove = MM_keepBoth
MM_moveParam = "index"

' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size > 0) Then
MM_moveParam = "offset"
If (MM_keepMove <> "") Then
params = Split(MM_keepMove, "&")
MM_keepMove = ""
For i = 0 To UBound(params)
nextItem = Left(params(i), InStr(params(i),"=") - 1)
If (StrComp(nextItem,MM_moveParam,1) <> 0) Then
MM_keepMove = MM_keepMove & "&" & params(i)
End If
Next
If (MM_keepMove <> "") Then
MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
End If
End If
End If

' set the strings for the move to links
If (MM_keepMove <> "") Then MM_keepMove = MM_keepMove & "&"
urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="
MM_moveFirst = urlStr & "0"
MM_moveLast = urlStr & "-1"
MM_moveNext = urlStr & Cstr(MM_offset + MM_size)
prev = MM_offset - MM_size
If (prev < 0) Then prev = 0
MM_movePrev = urlStr & Cstr(prev)
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = 10
Dim Repeat1__index
Repeat1__index = 0
lavagna_numRows = lavagna_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

' set the record count
lavagna_total = lavagna.RecordCount

' set the number of rows displayed on this page
If (lavagna_numRows < 0) Then
lavagna_numRows = lavagna_total
Elseif (lavagna_numRows = 0) Then
lavagna_numRows = 1
End If

' set the first and last displayed record
lavagna_first = 1
lavagna_last = lavagna_first + lavagna_numRows - 1

' if we have the correct record count, check the other stats
If (lavagna_total <> -1) Then
If (lavagna_first > lavagna_total) Then lavagna_first = lavagna_total
If (lavagna_last > lavagna_total) Then lavagna_last = lavagna_total
If (lavagna_numRows > lavagna_total) Then lavagna_numRows = lavagna_total
End If
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

' set the record count
lavagna_total = lavagna.RecordCount

' set the number of rows displayed on this page
If (lavagna_numRows < 0) Then
lavagna_numRows = lavagna_total
Elseif (lavagna_numRows = 0) Then
lavagna_numRows = 1
End If

' set the first and last displayed record
lavagna_first = 1
lavagna_last = lavagna_first + lavagna_numRows - 1

' if we have the correct record count, check the other stats
If (lavagna_total <> -1) Then
If (lavagna_first > lavagna_total) Then lavagna_first = lavagna_total
If (lavagna_last > lavagna_total) Then lavagna_last = lavagna_total
If (lavagna_numRows > lavagna_total) Then lavagna_numRows = lavagna_total
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (lavagna_total = -1) Then

' count the total records by iterating through the recordset
lavagna_total=0
While (Not lavagna.EOF)
lavagna_total = lavagna_total + 1
lavagna.MoveNext
Wend

' reset the cursor to the beginning
If (lavagna.CursorType > 0) Then
lavagna.MoveFirst
Else
lavagna.Requery
End If

' set the number of rows displayed on this page
If (lavagna_numRows < 0 Or lavagna_numRows > lavagna_total) Then
lavagna_numRows = lavagna_total
End If

' set the first and last displayed record
lavagna_first = 1
lavagna_last = lavagna_first + lavagna_numRows - 1
If (lavagna_first > lavagna_total) Then lavagna_first = lavagna_total
If (lavagna_last > lavagna_total) Then lavagna_last = lavagna_total

End If
%>
<%
' *** Move To Record and Go To Record: declare variables

Set MM_rs = lavagna
MM_rsCount = lavagna_total
MM_size = lavagna_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

' use index parameter if defined, otherwise use offset parameter
r = Request.QueryString("index")
If r = "" Then r = Request.QueryString("offset")
If r <> "" Then MM_offset = Int(r)

' if we have a record count, check if we are past the end of the recordset
If (MM_rsCount <> -1) Then
If (MM_offset >= MM_rsCount Or MM_offset = -1) Then ' past end or move last
If ((MM_rsCount Mod MM_size) > 0) Then ' last page not a full repeat region
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If

' move the cursor to the selected record
i = 0
While ((Not MM_rs.EOF) And (i < MM_offset Or MM_offset = -1))
MM_rs.MoveNext
i = i + 1
Wend
If (MM_rs.EOF) Then MM_offset = i ' set MM_offset to the last possible record

End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

' walk to the end of the display range for this page
i = MM_offset
While (Not MM_rs.EOF And (MM_size < 0 Or i < MM_offset + MM_size))
MM_rs.MoveNext
i = i + 1
Wend

' if we walked off the end of the recordset, set MM_rsCount and MM_size
If (MM_rs.EOF) Then
MM_rsCount = i
If (MM_size < 0 Or MM_size > MM_rsCount) Then MM_size = MM_rsCount
End If

' if we walked off the end, set the offset based on page size
If (MM_rs.EOF And Not MM_paramIsDefined) Then
If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
If ((MM_rsCount Mod MM_size) > 0) Then
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If

' reset the cursor to the beginning
If (MM_rs.CursorType > 0) Then
MM_rs.MoveFirst
Else
MM_rs.Requery
End If

' move the cursor to the selected record
i = 0
While (Not MM_rs.EOF And i < MM_offset)
MM_rs.MoveNext
i = i + 1
Wend
End If
%>
<%
' *** Move To Record: update recordset stats

' set the first and last displayed record
lavagna_first = MM_offset + 1
lavagna_last = MM_offset + MM_size
If (MM_rsCount <> -1) Then
If (lavagna_first > MM_rsCount) Then lavagna_first = MM_rsCount
If (lavagna_last > MM_rsCount) Then lavagna_last = MM_rsCount
End If

' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (lavagna_total = -1) Then

' count the total records by iterating through the recordset
lavagna_total=0
While (Not lavagna.EOF)
lavagna_total = lavagna_total + 1
lavagna.MoveNext
Wend

' reset the cursor to the beginning
If (lavagna.CursorType > 0) Then
lavagna.MoveFirst
Else
lavagna.Requery
End If

' set the number of rows displayed on this page
If (lavagna_numRows < 0 Or lavagna_numRows > lavagna_total) Then
lavagna_numRows = lavagna_total
End If

' set the first and last displayed record
lavagna_first = 1
lavagna_last = lavagna_first + lavagna_numRows - 1
If (lavagna_first > lavagna_total) Then lavagna_first = lavagna_total
If (lavagna_last > lavagna_total) Then lavagna_last = lavagna_total

End If
%>

cionci
30-04-2002, 19:26
Non mi hai capito...stampa a video la query al momento di farla...e così puoi vedere se ci sono problemi nella conversione da Date a String...

Cioè...ad esempio...per la prima query metti :
Response.Write "SELECT NomeUtente, CodiceContatto, COGNOME, DATA_APP, ORA_APP, RagioneSoc, NOMINATIVO, DATA_CON FROM Appuntamenti WHERE DATA_CON LIKE '" + Replace(lavagna__data, "'", "''") + "' AND EsitoTelf = 'Appuntamento' ORDER BY ORA_APP ASC"

scoppato
30-04-2002, 23:45
Scusa il malinteso!

la query che mi hai scritto dove devo inserirla? prima del tag <html>?
devo inserirla tra i simboli <%...%>?
sai non sono molto pratico di asp...

ti ringrazio molto!

lo scoppato:)

cionci
01-05-2002, 09:37
Prima di ogni query devi stampare il contenuto della query che vai ad eseguire sullos chermo per controllarne l'esattezza (soprattutto quelle sulle date)...

In pratica ti posizioni nella riga prima di ogni lavagna.Source = ...
Scrivi Response.Write e poi ci copi dopo la query che verrà eseguita...così riesci a vedere se ci sono errori nella generazione della stringa che verrà passata come query...

scoppato
01-05-2002, 11:06
ciao cionci! ho provato!
nella pagina viene visualizzato questo:

SELECT NomeUtente, CodiceContatto, COGNOME, DATA_APP, ORA_APP, RagioneSoc, NOMINATIVO, DATA_CON FROM Appuntamenti WHERE DATA_CON LIKE '01/05/2002' AND EsitoTelf = 'Appuntamento' ORDER BY ORA_APP ASC

come vedi è indicata la data 01/05/2002 che è corretto, ma la tabella che sta piu sotto continua a non darmi i risultati aspettati! nonostante nel db il campo DATA_CON abbia date coincidenti con 01/05/2002!

...boh!!!

cionci
01-05-2002, 11:14
Senti il campo DATA_CON di che tipo è ?

scoppato
01-05-2002, 11:26
il campo DATA_CON rappresenta la data di una contatto telefonico, in access è di tipo data in cifre nella forma gg/mm/aaaa.
sul mio portatile continua a funzionare ma sul PC server niente da fare!

cionci
01-05-2002, 11:32
Prova a correggere la query con DATA_CON == DateValue('01/05/2002')

Se non funziona così prova con DATA_CON >= DateValue('01/05/2002') And DATA_CON < DateValue('02/05/2002')

Fammi sapere...

scoppato
01-05-2002, 12:48
niente da fare!
non funziona!
i dati no vengono visualizzati!

cionci
01-05-2002, 16:12
Ma hai provato a vedere come ti viene visualizzata la query sul server oppure quella che hai riportato era la query visualizzata sul tuo computer ?

scoppato
03-05-2002, 14:42
ciao cionci!
ero via di casa e solo oggi ho visto la tua risposta!

ho provato con:

DATA_CON == DateValue('01/05/2002')

e anche con:

DATA_CON >= DateValue('01/05/2002') And DATA_CON < DateValue('02/05/2002')
sia su mio PC che sul Server.
Risultato: sul mio PC funziona tutto perfettamente, ma sul server non funziona!
spero di non romperti le ....

Mirkuz
03-05-2002, 15:16
Magari è una cazzata, ma a volte funziona...
Prima di SELECT etc... prova a scrivere SET DATEFORMAT DMY.
Questo gli dice di leggere le date in input come formate da giorno, mese e anno nell'ordine. Magari il tuo server ha le date settate a MDY (all'americana per intenderci).
Nella WHERE clause, poi, prova a mettere CAST('01/05/2002' as datetime) invece di '01/05/2002'.

Tutto ciò funziona in SQL Server...in Access non ho mai provato.

Comunque, per vedere se il problema è il formato della data, è sufficiente passargli una data tipo: '25/05/2002'. Se viene letta nel formato MDY ti dà errore (il mese 25 non esiste...:D)

Ciao,

scoppato
03-05-2002, 15:26
grazie per l'attenzione!
appena posso provo!
ti faccio sapere

ciauz :)