Buongiorno, non sono esperto di asp ed ho un problema di connessione al database che, per sicurezza, ho spostato da una cartella interna alla directory principale (wwwroot) ad una esterna (db).
attualmente la connessione è questa
sConn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/commerciale.mdb")
ma dovrei trasformarlo in qualcosa del genere che in altre pagine e per altri database funziona
sConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Domains\sandanielehomepage.it\db\commerciale.mdb;"
ma non so come fare, ho provato e mi viene restituito errore.
Posto tutto il codice del file globals.asp
<%
function Connection()
Dim cn,sConn
set cn = server.CreateObject("ADODB.connection")
sConn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/commerciale.mdb")
'sConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Domains\sandanielehomepage.it\db\commerciale.mdb;"
cn.Open sConn
set Connection= cn
set cn = nothing
end function
function GetDomConfig()
Dim dom
Set dom = Server.CreateObject("MSXML.DomDocument")
dom.async = false
if dom.load(server.MapPath("Config.xml")) then
Set GetDomConfig = dom
else
Response.Write "Errore durante il caricamento del file di configurazione"
Set GetDomConfig = nothing
end if
Set dom = nothing
end function
function OpenConnection(domConfig)
Dim cn
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open GetConnectionString(domConfig)
Set OpenConnection = cn
Set cn = nothing
end function
function GetConnectionString(domConfig)
GetConnectionString = domConfig.selectSingleNode("/Config/Connections/Connection[@ID=/Config/Connections/@IDCurrentConnection]/@Conn").text
end function
' function GetConnectionString(domConfig)
' Dim IDCurrentConnection
' Dim nodConnections
' Dim nodConnection
'
' Set nodConnections = domConfig.selectSingleNode("/Config/Connections")
' IDCurrentConnection = nodConnections.selectSingleNode("@IDCurrentConnection").text
'
' Set nodConnection = nodConnections.selectSingleNode("Connection[@ID=" & IDCurrentConnection & "]")
'
' GetConnectionString = nodConnection.selectSingleNode("@Conn").text
'
' Set nodConnections = nothing
' Set nodConnection = nothing
' end function
function getParamAsInt(sParamName, iDefaultValue)
if not isEmpty(Request.QueryString(sParamName)) then
getParamAsInt = cint(Request.QueryString(sParamName))
else
if not isEmpty(Request.Form(sParamName)) then
getParamAsInt = cint(Request.Form(sParamName))
else
getParamAsInt = cint(iDefaultValue)
end if
end if
end function
function getParamAsString(sParamName, sDefaultValue)
if not isEmpty(Request.QueryString(sParamName)) then
getParamAsString = cstr(Request.QueryString(sParamName))
else
if not isEmpty(Request.Form(sParamName)) then
getParamAsString = cstr(Request.Form(sParamName))
else
getParamAsString = cstr(sDefaultValue)
end if
end if
end function
function getSessionVariableAsInt(sVariableName, iDefaultValue)
if not isEmpty(Session(sVariableName)) then
getSessionVariableAsInt = cint(Session(sVariableName))
else
getSessionVariableAsInt = cint(iDefaultValue)
end if
end function
function setSessionVariableAsInt(sVariableName, iValue)
Session(sVariableName) = cint(iValue)
end function
function getIDTipoUtente(IDUtente,cn)
Dim rs,sSql
set rs=server.CreateObject("ADODB.recordset")
sSql="SELECT IDTipoUtente FROM tblUtentisuAziende WHERE IDUtentesuAzienda ="& IDUtente
rs.open sSql,cn
if not rs.eof then
IDTipoUtente=rs.fields("IDTipoUtente").value
else
IDTipoUtente= -1
end if
getIDTipoUtente = IDTipoUtente
rs.close
set rs= nothing
end function
function Contaaziende(idcat)
Dim rs, ssql,recaz
set rs=server.CreateObject("ADODB.recordset")
ssql="select IDcategoriasuAziende from tblAziende where IDcategoriasuaziende=" & idcat
rs.CursorLocation = 3
rs.CursorType = 1
rs.LockType = 3
rs.open ssql,cn,3,3
recaz=rs.recordcount
rs.close
Contaaziende=recaz
set rs= nothing
end function
%>
L'errore che viene restituito lo si vede su questa pagina http://www.sandanielehomepage.it/aziende/azienda_del_sandanielese.asp?IDAction=1&IDazienda=61
Potete aiutarmi?
attualmente la connessione è questa
sConn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/commerciale.mdb")
ma dovrei trasformarlo in qualcosa del genere che in altre pagine e per altri database funziona
sConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Domains\sandanielehomepage.it\db\commerciale.mdb;"
ma non so come fare, ho provato e mi viene restituito errore.
Posto tutto il codice del file globals.asp
<%
function Connection()
Dim cn,sConn
set cn = server.CreateObject("ADODB.connection")
sConn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/commerciale.mdb")
'sConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Domains\sandanielehomepage.it\db\commerciale.mdb;"
cn.Open sConn
set Connection= cn
set cn = nothing
end function
function GetDomConfig()
Dim dom
Set dom = Server.CreateObject("MSXML.DomDocument")
dom.async = false
if dom.load(server.MapPath("Config.xml")) then
Set GetDomConfig = dom
else
Response.Write "Errore durante il caricamento del file di configurazione"
Set GetDomConfig = nothing
end if
Set dom = nothing
end function
function OpenConnection(domConfig)
Dim cn
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open GetConnectionString(domConfig)
Set OpenConnection = cn
Set cn = nothing
end function
function GetConnectionString(domConfig)
GetConnectionString = domConfig.selectSingleNode("/Config/Connections/Connection[@ID=/Config/Connections/@IDCurrentConnection]/@Conn").text
end function
' function GetConnectionString(domConfig)
' Dim IDCurrentConnection
' Dim nodConnections
' Dim nodConnection
'
' Set nodConnections = domConfig.selectSingleNode("/Config/Connections")
' IDCurrentConnection = nodConnections.selectSingleNode("@IDCurrentConnection").text
'
' Set nodConnection = nodConnections.selectSingleNode("Connection[@ID=" & IDCurrentConnection & "]")
'
' GetConnectionString = nodConnection.selectSingleNode("@Conn").text
'
' Set nodConnections = nothing
' Set nodConnection = nothing
' end function
function getParamAsInt(sParamName, iDefaultValue)
if not isEmpty(Request.QueryString(sParamName)) then
getParamAsInt = cint(Request.QueryString(sParamName))
else
if not isEmpty(Request.Form(sParamName)) then
getParamAsInt = cint(Request.Form(sParamName))
else
getParamAsInt = cint(iDefaultValue)
end if
end if
end function
function getParamAsString(sParamName, sDefaultValue)
if not isEmpty(Request.QueryString(sParamName)) then
getParamAsString = cstr(Request.QueryString(sParamName))
else
if not isEmpty(Request.Form(sParamName)) then
getParamAsString = cstr(Request.Form(sParamName))
else
getParamAsString = cstr(sDefaultValue)
end if
end if
end function
function getSessionVariableAsInt(sVariableName, iDefaultValue)
if not isEmpty(Session(sVariableName)) then
getSessionVariableAsInt = cint(Session(sVariableName))
else
getSessionVariableAsInt = cint(iDefaultValue)
end if
end function
function setSessionVariableAsInt(sVariableName, iValue)
Session(sVariableName) = cint(iValue)
end function
function getIDTipoUtente(IDUtente,cn)
Dim rs,sSql
set rs=server.CreateObject("ADODB.recordset")
sSql="SELECT IDTipoUtente FROM tblUtentisuAziende WHERE IDUtentesuAzienda ="& IDUtente
rs.open sSql,cn
if not rs.eof then
IDTipoUtente=rs.fields("IDTipoUtente").value
else
IDTipoUtente= -1
end if
getIDTipoUtente = IDTipoUtente
rs.close
set rs= nothing
end function
function Contaaziende(idcat)
Dim rs, ssql,recaz
set rs=server.CreateObject("ADODB.recordset")
ssql="select IDcategoriasuAziende from tblAziende where IDcategoriasuaziende=" & idcat
rs.CursorLocation = 3
rs.CursorType = 1
rs.LockType = 3
rs.open ssql,cn,3,3
recaz=rs.recordcount
rs.close
Contaaziende=recaz
set rs= nothing
end function
%>
L'errore che viene restituito lo si vede su questa pagina http://www.sandanielehomepage.it/aziende/azienda_del_sandanielese.asp?IDAction=1&IDazienda=61
Potete aiutarmi?