CursorType a 0? :master:codice:rst.Open strSqlQuery,con,0,1
Mi sono perso.. che azione stai eseguendo per la query?
Insert (.addNew), update (.update) o semplice lettura?
Io suggerirei
codice:rst.Open strSqlQuery, con, 1
sto in insert (addnew)ho fatto la correzione che mi hai detto e ora l'errore è questo
Tipo di errore:
Errore di run-time di Microsoft VBScript (0x800A01FB)
Si è verificata un'eccezione: 'con.Open'
/Terzaera/connection.asp, line 20
dove la linea 20 è
con.Open ConnectionString
Se sei in insert cambia inOriginariamente inviato da brucola
sto in insert (addnew)ho fatto la correzione che mi hai detto e ora l'errore è questo
Tipo di errore:
Errore di run-time di Microsoft VBScript (0x800A01FB)
Si è verificata un'eccezione: 'con.Open'
/Terzaera/connection.asp, line 20
dove la linea 20 è
con.Open ConnectionString
e quel prob è risolto.codice:rst.Open strSqlQuery, con, 3, 3
Riguardo a quello sopra è un prob di stringa.
Leva i DSN ed unsa una stringa con percorso e driver OLEDB.![]()
mi da sempre quest'errore
Tipo di errore:
Errore di run-time di Microsoft VBScript (0x800A01FB)
Si è verificata un'eccezione: 'con.Open'
/Terzaera/connection.asp, line 20
Posta il codice attuale.Originariamente inviato da brucola
mi da sempre quest'errore
Tipo di errore:
Errore di run-time di Microsoft VBScript (0x800A01FB)
Si è verificata un'eccezione: 'con.Open'
/Terzaera/connection.asp, line 20
Usa il tad CODE.
codice:<%
<%
Session("Debug")= false
Dim con
Dim rst
Dim cmd
Dim ErrorMsg
Dim OkMsg
Dim ConnectionString
Sub OpenCon
Set con = Server.CreateObject("ADODB.Connection")
'ConnectionString = "DSN=NomeDSN;UID=user;PWD=password;"
ConnectionString = "DSN=locale;UID=root;PWD=;"
End Sub
Sub OpenConWrite
OpenCon
con.Open ConnectionString
End Sub
Sub OpenConRead
OpenCon
con.Mode = 1
con.Open ConnectionString
End Sub
Function OpenConCommand(strSqlQuery)
con.Execute strSqlQuery,n
OpenConCommand = n
End Function
Sub CloseCon
If not isempty(con) then
If not (con is nothing) then
if con.State = 1 then con.Close
End If
End If
set con = nothing
End Sub
Sub OpenRst(strSqlQuery)
Set rst = Server.CreateObject("ADODB.recordset")
rst.CursorLocation = 3
'response.Write strSqlQuery
'response.End
rst.Open strSqlQuery, con, 1
End Sub
Sub OpenRstWrite(strSqlQuery)
Set rst = Server.CreateObject("ADODB.recordset")
rst.CursorLocation = 3
rst.Open strSqlQuery, con, 3, 3
End Sub
Sub CloseRst
if not isempty(rst) then
if not (rst is nothing) then
if rst.State = 1 then rst.Close
End If
End If
set rst = nothing
End Sub
Sub OpenCmd(strSqlCommandText)
set cmd = Server.CreateObject("ADODB.Command")
set cmd.ActiveConnection = con
cmd.CommandText = strSqlCommandText
End Sub
Sub CloseCmd
set cmd = nothing
End Sub
Public Function EmptyRecordset()
If Not rst.BOF And Not rst.EOF Then
EmptyRecordset = False
Else
EmptyRecordset = True
End If
End Function
'-----------------------------------------------------------------------------'
' Funzione Esiste (tabella,condizione)
' Restituisce un valore booleano TRUE se c'è almeno un record che corrisponde alla condizione
' altrimenti restituisce false
'-----------------------------------------------------------------------------'
Public Function Esiste (tabella,condizione)
strSqlQuery = "select * from " & utenti & " where " & condizione
'response.Write strSqlQuery
'response.End
call OpenRst(strSqlQuery)
if EmptyRecordset() then
flg = false
else
flg = true
end if
closerst
Esiste = flg
End Function
'-----------------------------------------------------------------------------'
' Funzione GetArrayRes (strSqlQuery)
' Restituisce un array ricavato dal recorset o una stringa vuota nel caso
' il recordset fosse vuoto
'-----------------------------------------------------------------------------'
Public Function GetArrayRes (strSqlQuery)
call OpenRst(strSqlQuery)
if EmptyRecordset() then
flg = ""
else
flg = rst.Getrows()
end if
closerst
GetArrayRes = flg
End Function
'-----------------------------------------------------------------------------'
' Funzione GetScalare (strSqlQuery,vdefault)
' Restituisce uno scalare nella psizione 0,0 dell'array ricavato dal recorset
' o il valore di default
'-----------------------------------------------------------------------------'
Public Function GetScalare (strSqlQuery, vdefault)
arr_tmp = getArrayRes(strSqlQuery)
if isarray(arr_tmp) then
flg = arr_tmp(0,0)
else
flg = vdefault
end if
GetScalare = flg
End Function
'Funzione per compilare record in tabella generica
sub InserisciCampi(tabella,listacampi,listavalori)
call openRstWrite("select * from "&utenti&" ")
arr_lista_campi= split(listacampi,"|")
arr_lista_valori= split(listavalori,"|")
response.write listacampi
rst.AddNew
for i= 0 to ubound(arr_lista_campi)
if arr_lista_valori(i) = "XXX_NOW" then
rst(arr_lista_campi(i)) = now()
else
rst(arr_lista_campi(i)) = arr_lista_valori(i)
end if
next
rst.Update
closerst
End sub
'recupera il prossimo numero disponibile
' (Da mettere sotto transazione con blocco numero)
Function GetMaxElement(campo,tabella)
sql = "select max("&campo&") as usrnum from "&tabella&""
openrst(sql)
if Emptyrecordset then
nuovoUtente = 1
else
if isvarnull(rst("usrnum")) then
nuovoUtente = 1
else
nuovoUtente = rst("usrnum") + 1
end if
end if
closerst
GetMaxElement = nuovoUtente
End Function
%>
scusa ma non sono riuscito ad usarlo il tasto code
Come non sei riuscito ad usarlo... :master:
- vai su modalità avanzata
- oppure scrivi [ CODE ] il codice e [ /CODE ] senza spazi elle parentesi.
Così viene male agli occhi.
E poi vedo che hai seguito il consiglio della connessione con OLEDB.![]()
codice:<% Session("Debug")= false Dim con Dim rst Dim cmd Dim ErrorMsg Dim OkMsg Dim ConnectionString Sub OpenCon Set con = Server.CreateObject("ADODB.Connection") 'ConnectionString = "DSN=NomeDSN;UID=user;PWD=password;" ConnectionString = "DSN=locale;UID=root;PWD=;" End Sub Sub OpenConWrite OpenCon con.Open ConnectionString End Sub Sub OpenConRead OpenCon con.Mode = 1 con.Open ConnectionString End Sub Function OpenConCommand(strSqlQuery) con.Execute strSqlQuery,n OpenConCommand = n End Function Sub CloseCon If not isempty(con) then If not (con is nothing) then if con.State = 1 then con.Close End If End If set con = nothing End Sub Sub OpenRst(strSqlQuery) Set rst = Server.CreateObject("ADODB.recordset") rst.CursorLocation = 3 'response.Write strSqlQuery 'response.End rst.Open strSqlQuery, con, 1 End Sub Sub OpenRstWrite(strSqlQuery) Set rst = Server.CreateObject("ADODB.recordset") rst.CursorLocation = 3 rst.Open strSqlQuery, con, 3, 3 End Sub Sub CloseRst if not isempty(rst) then if not (rst is nothing) then if rst.State = 1 then rst.Close End If End If set rst = nothing End Sub Sub OpenCmd(strSqlCommandText) set cmd = Server.CreateObject("ADODB.Command") set cmd.ActiveConnection = con cmd.CommandText = strSqlCommandText End Sub Sub CloseCmd set cmd = nothing End Sub Public Function EmptyRecordset() If Not rst.BOF And Not rst.EOF Then EmptyRecordset = False Else EmptyRecordset = True End If End Function '-----------------------------------------------------------------------------' ' Funzione Esiste (tabella,condizione) ' Restituisce un valore booleano TRUE se c'è almeno un record che corrisponde alla condizione ' altrimenti restituisce false '-----------------------------------------------------------------------------' Public Function Esiste (tabella,condizione) strSqlQuery = "select * from " & utenti & " where " & condizione 'response.Write strSqlQuery 'response.End call OpenRst(strSqlQuery) if EmptyRecordset() then flg = false else flg = true end if closerst Esiste = flg End Function '-----------------------------------------------------------------------------' ' Funzione GetArrayRes (strSqlQuery) ' Restituisce un array ricavato dal recorset o una stringa vuota nel caso ' il recordset fosse vuoto '-----------------------------------------------------------------------------' Public Function GetArrayRes (strSqlQuery) call OpenRst(strSqlQuery) if EmptyRecordset() then flg = "" else flg = rst.Getrows() end if closerst GetArrayRes = flg End Function '-----------------------------------------------------------------------------' ' Funzione GetScalare (strSqlQuery,vdefault) ' Restituisce uno scalare nella psizione 0,0 dell'array ricavato dal recorset ' o il valore di default '-----------------------------------------------------------------------------' Public Function GetScalare (strSqlQuery, vdefault) arr_tmp = getArrayRes(strSqlQuery) if isarray(arr_tmp) then flg = arr_tmp(0,0) else flg = vdefault end if GetScalare = flg End Function 'Funzione per compilare record in tabella generica sub InserisciCampi(tabella,listacampi,listavalori) call openRstWrite("select * from "&utenti&" ") arr_lista_campi= split(listacampi,"|") arr_lista_valori= split(listavalori,"|") response.write listacampi rst.AddNew for i= 0 to ubound(arr_lista_campi) if arr_lista_valori(i) = "XXX_NOW" then rst(arr_lista_campi(i)) = now() else rst(arr_lista_campi(i)) = arr_lista_valori(i) end if next rst.Update closerst End sub 'recupera il prossimo numero disponibile ' (Da mettere sotto transazione con blocco numero) Function GetMaxElement(campo,tabella) sql = "select max("&campo&") as usrnum from "&tabella&"" openrst(sql) if Emptyrecordset then nuovoUtente = 1 else if isvarnull(rst("usrnum")) then nuovoUtente = 1 else nuovoUtente = rst("usrnum") + 1 end if end if closerst GetMaxElement = nuovoUtente End Function %>