Salve a tutti, ho un'applicazione scritta in classic asp. Sto cercando di aggiundere una nuova funzionalità e funziona tutto finchè non devo visualizzare il contenuto di una tabella attraverso una sempicissima query
SELECT * FROM [mia_tabella] WHERE id = 14
e mi restituisce sempre l'errore
Microsoft VBScript runtime error '800a0006', Overflow: '[number: 35521]' oltretutto non capisco cosa sia quel numero 35521...
Ho una classe Controller che richiama una funzione e poi passa ad una View il risultato della funzione e quindi
<%
class StoricoSQAController
Dim ModelStoricoSQA
Dim ViewData
private sub Class_Initialize()
Set ViewData = Server.CreateObject("Scripting.Dictionary")
end sub
private sub Class_Terminate()
end sub
public sub List(vars)
Dim h_SSQA, results
set h_SSQA = new StoricoSQAHelper
set results = h_SSQA.SelectByFornitoreId(vars("id"))
%> <!--#inlcude file="../Views/StoricoSQA/List"--> <%
end sub
public sub Details(vars)
Dim sqa_helper
set sqa_helper = new StoricoSQAHelper
set ModelStoricoSQA = sqa_helper.SelectById(vars("id"))
%> <!--#inlcude file="../Views/StoricoSQA/Details"--> <%
end sub
end class
%>
<%
'
' This files defines the Storico_SQA model
'
class StoricoSQA
'=============================
'Private properties
private mId
private mFornitore_id
'Private properties SQA
private mSQA_criterioA_1
private mSQA_criterioA_2
private mSQA_criterioA_3
private mSQA_criterioB
private mSQA_criterioC
private mSQA_usage_1
private mSQA_usage_2
private mSQA_perSqa
private mSQA_carenze
private mSQA_azioni
private mSQA_data_inserimento
private mSQA_nomeUtente
private mSQA_utente_id
private mSQA_riserva
private mSQA_completato
private mUpdated_at
private mUpdated_from
private mUpdated_utente_id
private sub Class_Initialize()
end sub
private sub Class_Terminate()
end sub
'=============================
'public properties
public property get Id()
Id = mId
end property
public property let Id(val)
mId = val
end property
public property get Fornitore_Id()
Fornitore_Id = mFornitore_Id
end property
public property let Fornitore_Id(val)
mFornitore_Id = val
end property
' Public properties SQA
public property get SQA_criterioA_1()
SQA_criterioA_1 = mSQA_criterioA_1
end property
public property let SQA_criterioA_1(val)
mSQA_criterioA_1 = val
end property
public property get SQA_criterioA_2()
SQA_criterioA_2 = mSQA_criterioA_2
end property
public property let SQA_criterioA_2(val)
mSQA_criterioA_2 = val
end property
public property get SQA_criterioA_3()
SQA_criterioA_3 = mSQA_criterioA_3
end property
public property let SQA_criterioA_3(val)
mSQA_criterioA_3 = val
end property
public property get SQA_criterioB()
SQA_criterioB = mSQA_criterioB
end property
public property let SQA_criterioB(val)
mSQA_criterioB = val
end property
public property get SQA_criterioC()
SQA_criterioC = mSQA_criterioC
end property
public property let SQA_criterioC(val)
mSQA_criterioC = val
end property
public property get SQA_usage_1()
SQA_usage_1 = mSQA_usage_1
end property
public property let SQA_usage_1(val)
mSQA_usage_1 = val
end property
public property get SQA_usage_2()
SQA_usage_2 = mSQA_usage_2
end property
public property let SQA_usage_2(val)
mSQA_usage_2 = val
end property
public property get SQA_perSqa()
SQA_perSqa = mSQA_perSqa
end property
public property let SQA_perSqa(val)
mSQA_perSqa = val
end property
public property get SQA_carenze()
SQA_carenze = mSQA_carenze
end property
public property let SQA_carenze(val)
mSQA_carenze = val
end property
public property get SQA_azioni()
SQA_azioni = mSQA_azioni
end property
public property let SQA_azioni(val)
mSQA_azioni = val
end property
public property get SQA_data_inserimento()
SQA_data_inserimento = mSQA_data_inserimento
end property
public property let SQA_data_inserimento(val)
mSQA_data_inserimento = val
end property
public property get SQA_utente_id()
SQA_utente_id = mSQA_utente_id
end property
public property let SQA_utente_id(val)
mSQA_utente_id = val
end property
public property get SQA_nomeUtente()
SQA_nomeUtente = mSQA_nomeUtente
end property
public property let SQA_nomeUtente(val)
mSQA_nomeUtente = val
end property
public property get SQA_riserva()
SQA_riserva = mSQA_riserva
end property
public property let SQA_riserva(val)
mSQA_riserva = val
end property
public property get SQA_completato()
SQA_completato = mSQA_completato
end property
public property let SQA_completato(val)
mSQA_completato = val
end property
public property get Updated_at()
Updated_at = mUpdated_at
end property
public property let Updated_at(val)
mUpdated_at = val
end property
public property get Updated_from()
Updated_from = mUpdated_from
end property
public property let Updated_from(val)
mUpdated_from = val
end property
public property get Updated_utente_id()
Updated_utente_id = mUpdated_utente_id
end property
public property let Updated_utente_id(val)
mUpdated_utente_id = val
end property
end class
'======================
class StoricoSQAHelper
Dim selectSQL
private sub Class_Initialize()
selectSQL = " SELECT * FROM [Storico_SQA] "
end sub
private sub Class_Terminate()
end sub
'=============================
'public Functions
public function Insert(obj)
Dim strSQL
strSQL = " INSERT INTO [Storico_SQA] (fornitore_id, SQA_criterioA_1, SQA_criterioA_2, SQA_criterioA_3, SQA_criterioB, SQA_criterioC, SQA_usage_1, SQA_usage_2, SQA_perSqa, SQA_carenze, SQA_azioni, SQA_nomeUtente, SQA_data_inserimento, SQA_utente_id, SQA_riserva, SQA_completato, updated_at, updated_from, updated_utente_id ) " &_
"VALUES ({0},{1},{2},{3},{4},{5},{6}, {7},{8},'{9}','{10}', '{11}', '{12}', {13}, {14}, {15}, '{16}', '{17}', {18} )"
obj.Id = DbExecute (StringFormat(strSQL, array(obj.fornitore_id, Abs(CInt(obj.SQA_criterioA_1)), Abs(CInt(obj.SQA_criterioA_2)), Abs(CInt(obj.SQA_criterioA_3)), Abs(CInt(obj.SQA_criterioB)), Abs(CInt(obj.SQA_criterioC)), Abs(CInt(obj.SQA_usage_1)), Abs(CInt(obj.SQA_usage_2)), Abs(CInt(obj.SQA_perSQA)), obj.SQA_carenze, obj.SQA_azioni, obj.SQA_nomeUtente, obj.SQA_data_inserimento, obj.SQA_utente_id, Abs(CInt(obj.SQA_riserva)), Abs(CInt(obj.SQA_completato)), obj.updated_at, obj.updated_from, obj.updated_utente_id)))
Insert = false
DbCloseConnection
end function
public function SelectById(id)
Dim record
set record = DbExecute(StringFormat(selectSQL + " WHERE Id = {0}", array(id)))
Set SelectById = PopulateObjectFromRecord(record)
record.Close
set record = nothing
DbCloseConnection
end function
public function SelectAll()
Dim records
set records = DbExecute(selectSQL)
if records.eof then
Set SelectAll = Nothing
else
Dim results, obj, record
Set results = Server.CreateObject("Scripting.Dictionary")
while not records.eof
set obj = PopulateObjectFromRecord(records)
results.Add obj.Id, obj
records.movenext
wend
set SelectAll = results
records.Close
End If
set record = nothing
DbCloseConnection
end function
public function SelectByFornitoreId(id)
Dim recordFid
set recordFid = DbExecute(StringFormat(selectSQL + " WHERE fornitore_id = {0}", array(id)))
if recordFid.eof then
Set SelectByFornitoreId = Nothing
else
Dim results, obj, record
Set results = Server.CreateObject("Scripting.Dictionary")
while not recordFid.eof
set obj = PopulateObjectFromRecord(recordFid)
results.Add obj.Id, obj
recordFid.movenext
wend
set SelectByFornitoreId = results
recordFid.Close
End If
set recordFid = nothing
DbCloseConnection
end function
public function SelectByField(fieldName, value)
Dim records, txtSQL
txtSQL = StringFormat(selectSQL + " where " + fieldName + "={0}" , array(value))
set records = DbExecute(txtSQL)
if records.eof then
Set SelectByField = Nothing
else
Dim results, obj, record
Set results = Server.CreateObject("Scripting.Dictionary")
while not records.eof
set obj = PopulateObjectFromRecord(records)
results.Add obj.Id, obj
records.movenext
wend
set SelectByField = results
records.Close
End If
set records = nothing
DbCloseConnection
end function
private function PopulateObjectFromRecord(records)
if records.eof then
Set PopulateObjectFromRecord = Nothing
else
Dim storicoSQA
set storicoSQA = new StoricoSQA
storicoSQA.Id = records("Id")
storicoSQA.Fornitore_id = records("fornitore_id")
storicoSQA.SQA_criterioA_1 = records("SQA_criterioA_1")
storicoSQA.SQA_criterioA_2 = records("SQA_criterioA_2")
storicoSQA.SQA_criterioA_3 = records("SQA_criterioA_3")
storicoSQA.SQA_criterioB = records("SQA_criterioB")
storicoSQA.SQA_criterioC = records("SQA_criterioC")
storicoSQA.SQA_usage_1 = records("SQA_usage_1")
storicoSQA.SQA_usage_2 = records("SQA_usage_2")
storicoSQA.SQA_perSQA = records("SQA_perSQA")
storicoSQA.SQA_carenze = records("SQA_carenze")
storicoSQA.SQA_azioni = records("SQA_azioni")
storicoSQA.SQA_data_inserimento = records("SQA_data_inserimento")
storicoSQA.SQA_nomeUtente = records("SQA_nomeUtente")
storicoSQA.SQA_utente_id = records("SQA_utente_id")
storicoSQA.SQA_riserva = records("SQA_riserva")
storicoSQA.SQA_completato = records("SQA_completato")
storicoSQA.Updated_at = records("updated_at")
storicoSQA.Updated_from = records("updated_from")
storicoSQA.Updated_utente_id = records("updated_utente_id")
set PopulateObjectFromRecord = storicoSQA
end if
end function
end class 'StoricoSQAHelper
%>
Ho poi un file Default.asp che gestisce le rotte che è il seguente
<%
Const defaultController = "Home"
Const defaultAction = "Index"
If not Route () then
result = RouteDebug ()
End If
Function ContentPlaceHolder()
If not Route () then
result = RouteDebug ()
End If
End Function
Function Route ()
Dim controller, action , vars
controller = Request.QueryString("controller")
action = Request.QueryString("action")
set vars = CollectVariables()
Route = False
If IsEmpty(controller) or IsNull(controller) then
controller = defaultController
End If
If IsEmpty(action) or IsNull(action) then
action = defaultAction
End If
Dim controllerName
controllerName = controller + "Controller"
Dim controllerInstance
Set controllerInstance = Eval ( " new " + controllerName)
Dim actionCallString
If (Instr(1,action,"Post",1)>0) then
actionCallString = " controllerInstance." + action + "(Request.Form)"
ElseIf Not (IsNothing(vars)) then
actionCallString = " controllerInstance." + action + "(vars)"
Else
actionCallString = " controllerInstance." + action + "()"
End If
Eval (actionCallString)
Route = true
End Function
Function RouteDebug ()
Dim controller, action , vars
controller = Request.QueryString("controller")
action = Request.QueryString("action")
Response.Write(controller)
Response.Write(action)
dim key, keyValue
for each key in Request.Querystring
keyValue = Request.Querystring(key)
'ignore service keys
if InStr(1,"controller, action, partial",key,1)=0 Then
Response.Write( key + " = " + keyValue )
End If
next
End Function
Function CollectVariables
dim key, keyValue
Set results = Server.CreateObject("Scripting.Dictionary")
for each key in Request.Querystring
keyValue = Request.Querystring(key)
'ignore service keys
if InStr(1,"controller, action, partial",key,1)=0 Then
results.Add key,keyValue
End If
next
if results.Count=0 Then
Set CollectVariables = Nothing
else
Set CollectVariables = results
End If
End Function
%>
Ora richiamando il tutto attraverso l'url
miaApp/Default.asp?controller=StoricoSQA&action=List&id=14 ricevo sempre lo stesso messaggio di errore e cioè
Microsoft VBScript runtime error '800a0006'
Overflow: '[number: 35521]'
/miaApp/Controllers/StoricoSQAController.asp, line 16
che corrisponde alla riga
set results = h_SSQA.SelectByFornitoreId(vars("id")).
Il codice è standard per tutte le altre tabelle del database per cui non riesco proprio a capire perchè qui non funziona e con altre tabelle si.
Se qualcuno riesce ad aiutarmi ne sarei felice e tanto tanto grato.
P.S.: perdonatemi per la lunghezza del codice....