Ir para conteúdo
Fórum Script Brasil
  • 0

Alguém Sabe O Erro


maktub

Pergunta

Pequei um portal na app mas não consigo faze-lo funcionar, a pagina aponta o erro:

Unable to connect to application database. This database is defined by the connection string located in the 'global.asa' file for this site. 

Possible causes: 
The syntax of the connection string is incorrect 
A connection string attribute (ie; dsn, database, uid, pwd, etc..) is incorrect 
The database server is temporarily unavailable 
The 'global.asa' file must be located in the Web site (application) root (this may be separate from the other PortalApp files) 


Open the 'global.asa' file to verify the cn_str assignment. 
Olhei o Global.asa, mas parece estar em ordem, o que pode estar acontecendo? Global.asa:
<!-- place this file, or edit the exisiting "global.asa" file in the web site root folder -->

<object runat="server" scope="application" id="online_users" progid="scripting.dictionary"></object>

<script LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart

	':: app database connection string
	application("cn_str") = "provider=microsoft.jet.oledb.4.0;data source=" & server.MapPath("C:\Inetpub\wwwroot\portal\data\8681.MDB") & ""

	':: initilize application variables from database
	set cn = Server.CreateObject("ADODB.Connection")
	cn.Open application("cn_str")
	set rs = cn.Execute("SELECT * FROM AppSettings")
	for each field in rs.Fields
  application(field.Name) = field.Value
	next
  
End Sub

Sub Session_OnStart

	session.timeout = 20

End Sub

Sub Session_OnEnd

	if isObject(online_users) then
  on error resume next
  online_users.remove (session.sessionid)
	end if

End Sub

</SCRIPT>

Ajudem-me

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

Observer o caminho do seu banco de dados:

server.MapPath("C:\Inetpub\wwwroot\portal\data\8681.MDB")

Se estiver no mesmo diretorio ultilize o seguinte:

<%
 cBanco = Server.MapPath("8681.mdb")
 application("cn_str") = "provider=microsoft.jet.oledb.4.0;data source="& cBanco 
%>

wink.gif

Link para o comentário
Compartilhar em outros sites

  • 0

Fala ai brother belezinha, cara eu tentei esta conexão mas não deu, bom para entender melhor:

Tem um cara chamado i_utilis.asp que executa o comando:

<%

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::::: i_utils.asp global function library for aspapp.com  :::::::::
':::::: copyright 1999-2004 Iatek. All rights reserved.  ::::::::
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
''  GLOBAL DECLARATIONS AND DATABASE CONNECTIONS
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

''' initiate global vars and constants
dim action
dim b_error, a_errors, error_list, a_msg, msg_list
dim cn, cmd, rs, rsselect, sql, do_search, a_records

''' instantiate error handling and messaging
set error_list = CreateObject("Scripting.Dictionary")
set msg_list = CreateObject("Scripting.Dictionary")

''' initiate db objects and connections

''' app database
set cn = Server.CreateObject("ADODB.Connection")
set user_cn = Server.CreateObject("ADODB.Connection")

on error resume next
cn.Open application("cn_str")
user_cn.Open application("cn_str")
if err.number <> 0 then response.redirect "error.asp"
on error goto 0

''' command object
set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cn

''' recordset object
set rs = Server.CreateObject("ADODB.Recordset")

''' set locale identifier - default is US English
''' (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsmsclcid.asp)
session.lcid = 1033

''' set proper contcanation operator
if inStr(lcase(cn.Provider),"jet") = 0 then
	'' SQL	
	cn.Execute ("SET CONCAT_NULL_YIELDS_NULL OFF")
	cc = "+"
else
	'' Access concatentation
	cc = "&"
end if


'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
''  ERROR AND MESSAGE DISPLAY SUBS
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

sub display_errs
':::::::::::::::::::::::::::::::::::::::::::::::::::::
	' display content of the error dictionary object
':::::::::::::::::::::::::::::::::::::::::::::::::::::
if error_list.count > 0 then
	''' display errors
	a_errors = error_list.items
	for i = 0 to error_list.count - 1
	response.write "<div class=ErrFont>" & a_errors(i) & "</div>"
	next
end if
end sub

sub display_msg
':::::::::::::::::::::::::::::::::::::::::::::::::::::
' displays msgs after successful database action
':::::::::::::::::::::::::::::::::::::::::::::::::::::
	':: check if a msg was passed to the page
	if request("msg") <> "" then
  msg = replace(request("msg"),"://","")
  msg = replace(msg,"script","")
  msg = replace(msg,"%","")
  msg = replace(msg,"form","")
  msg_list.add "msg",msg
	end if
	':: display messages
	a_msg = msg_list.items
	for i = 0 to msg_list.count - 1
  response.write "<div class=MsgFont>" & a_msg(i) & "</div>"
	next
end sub



'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
''  USER MANAGMENT FUNCTIONS
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

function check_security(iLevel)
':::::::::::::::::::::::::::::::::::::::::::::::::::::
' authenticates user and verifies access level
':::::::::::::::::::::::::::::::::::::::::::::::::::::
	if session("user_id") = "" OR isNull(session("accesslevel")) then
  response.redirect("login.asp?ret_page=" & to_url(request.serverVariables("SCRIPT_NAME")&"?"&request.serverVariables("QUERY_STRING")))
	elseif session("accesslevel") <> "" then
  if cLng(session("accesslevel")) < cLng(iLevel) then response.redirect("login.asp?action=noaccess&ret_page=" & to_url(request.serverVariables("SCRIPT_NAME")&"?"&request.serverVariables("QUERY_STRING")))
	else
  user_id = session("user_id")
  accesslevel = session("accesslevel")
	end if
end function

sub do_login
':::::::::::::::::::::::::::::::::::::::::::::::::::::
' autheticates user in db and creates session
':::::::::::::::::::::::::::::::::::::::::::::::::::::
	sql = "SELECT user_name, password FROM Users WHERE user_name = " & to_sql(user_name,"text") & " AND password = " & to_sql(password,"text") & ""
	set rs = user_cn.Execute(sql)
    	if rs.EOF then
  'login failed
  error_list.add "login", "Login or password is incorrect."
  b_error = true
	else
  'login and password passed
  sql = "SELECT user_id, accesslevel FROM Users WHERE user_name = " & to_sql(user_name,"text") & " AND password = " & to_sql(password,"text") & ""
  set rs = user_cn.Execute(sql)
     
  if rs.EOF then
  	'should never happen
  	error_list.add "login", "User does not exist."
  	b_error = true
  else
  	'login user
  	session("user_id") = rs(0)
  	session("accesslevel") = rs(1)

  	'add user_name to app dict (global.asa)
  	if isObject(online_users) then online_users.item(session.sessionid) = session("user_id") & "," & user_name
  	
  	'store last visit date in session, set current date in db
  	on error resume next
  	set rs = user_cn.Execute("SELECT dtlast FROM Users WHERE user_id = " & to_sql(session("user_id"),"number"))
  	session("dtlast") = rs(0)
  	if err.number = 0 then user_cn.Execute = "UPDATE Users SET last_ip='" & Request.ServerVariables("REMOTE_ADDR") & "', dtlast = " & to_sql(now,"date") & " WHERE user_id = " & to_sql(session("user_id"),"number")
  	on error goto 0	

  	'where to next?
  	querystring = request("querystring")
  	ret_page = request("ret_page")
  	if (ret_page <> request.serverVariables("SCRIPT_NAME")) AND (ret_page <> "") then
    'return to page that preceded login
      	response.redirect(ret_page)
  	else
    'go home
    response.redirect("default.asp")
  	end if
  end if
	end if
	rs.Close
      
end sub



'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
''  FORMATTING FUNCTIONS
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

function to_url(strValue)
':::::::::::::::::::::::::::::::::::::::::::::::::::::
' make passed paramters url friendly
':::::::::::::::::::::::::::::::::::::::::::::::::::::
	if IsNull(strValue) then strValue = ""
	to_url = Server.URLEncode(strValue)
end function

function to_html(strValue)
':::::::::::::::::::::::::::::::::::::::::::::::::::::
' convert and clean string
':::::::::::::::::::::::::::::::::::::::::::::::::::::
	if IsNull(strValue) then strValue = ""
	strValue = Replace(strValue,"&lt;%","<"&chr(37))
	strValue = Replace(strValue,"%&gt;",chr(37)&">")
	strValue = Replace(strValue,"&lt;script","<script",1)
	strValue = Replace(strValue,"&lt;/script&gt","</script>",1)	
	to_html = Server.HTMLEncode(strValue)
end function


function to_sql(Value,DataType)

	dim dteDateTime
	dteDateTime = Value

	if Value = "" or isNull(Value) then
  to_sql = "NULL"
	elseif (DataType = "date" OR DataType = "absdate") then
  	if IsDate(dteDateTime) = True then
  	if DataType="date" AND Hour(dteDateTime)>0 AND application("server_time_diff")<>0 AND not isNull(application("server_time_diff")) then dteDateTime = DateAdd("H",application("server_time_diff"),dteDateTime)
  	dim dteDay, dteMonth, dteYear, dteHour, dteMinute, dteSecond
  	dteDay = Day(dteDateTime)
  	dteMonth = Month(dteDateTime)
  	dteYear = Year(dteDateTime)
  	dteHour = Hour(dteDateTime)
  	dteMinute = Minute(dteDateTime)
  	dteSecond = Second(dteDateTime)
  	dteDateTime = dteYear & _
    "-" & Right(Cstr(dteMonth + 100),2) & _
    "-" & Right(Cstr(dteDay + 100),2) & _
    " " & Right(Cstr(dteHour + 100),2) & _
    ":" & Right(Cstr(dteMinute + 100),2) & _
    ":" & Right(Cstr(dteSecond + 100),2)
    if instr(lcase(cn.Provider),"jet")>0 then
    ':access
    to_sql = "#" & Replace(dteDateTime, "'", "''") & "#"
    else
    ':sql server
    to_sql = "'" & Replace(dteDateTime, "'", "''") & "'"
    end if
  	else
    to_sql = "NULL"
  	end if
	elseif DataType <> "number" then
  Value = Replace(Value,"<"&chr(37),"&lt;%")
  Value = Replace(Value,chr(37)&">","%&gt;")
  Value = Replace(Value,"<script","&lt;script",1)
  Value = Replace(Value,"</script>","&lt;/script&gt",1)
  to_sql = "'" & Replace(Value, "'", "''") & "'"
	elseif inStr(Value,".") then
  to_sql = Value
	else
  to_sql = cLng(Value)
	end if

end function
':::::::::::::::::::::::::::::::::::::::::::



function strip_html(str_html)
':::::::::::::::::::::::::::::::::::::::::::::::::::::
' removes html tags from str_html
':::::::::::::::::::::::::::::::::::::::::::::::::::::
	dim objRegExp, str_output
	set objRegExp = new Regexp

	objRegExp.IgnoreCase = True
	objRegExp.Global = True
	objRegExp.Pattern = "<(.|\n)+?>"

	str_output = objRegExp.Replace(str_html, "")
	str_output = Replace(str_output, "<", "&lt;")
	str_output = Replace(str_output, ">", "&gt;")
	strip_html = str_output
	set objRegExp = Nothing
end function

function get_options(sql,selected_value)
':::::::::::::::::::::::::::::::::::::::::::::::::::::
' displays option tags for a select list
':::::::::::::::::::::::::::::::::::::::::::::::::::::
	'response.write sql
	if isNull(selected_value) then selected_value = ""
	set rsSelect = cn.Execute(sql)
	do until rsSelect.EOF
  if not isNull(rsSelect(0)) then
  	get_options = get_options + "<option"
  	if cStr(rsSelect(0)) = cStr(selected_value) then
    get_options = get_options + " SELECTED"
  	end if
  	get_options = get_options + " value='" & rsSelect(0) & "'>"
  	if rsSelect.Fields.Count-1 = 0 then
    get_options = get_options + "" & rsSelect(0) & " "
  	else
    for i = 1 to rsSelect.Fields.Count-1
    	if rsSelect(i) <> "" then
      get_options = get_options + "" & rsSelect(i)
      if i < rsSelect.Fields.Count-1 then get_options = get_options + ": "
    	end if
    next
  	end if
  	get_options = get_options + "</option>" & vbCRLF & chr(9) & chr(9)
  end if
	rsSelect.MoveNext
	loop
	rsSelect.Close
end function

function is_reserved(strValue)
':::::::::::::::::::::::::::::::::::::::::::::::::::::
' compare a string with a list of vb and sql reserved words
':::::::::::::::::::::::::::::::::::::::::::::::::::::
	reserved_words = "|and||as||boolean||byref||byte||byval||call||case||class||const||currency||date||desc||debug||dim||do||double||each||else||elseif||empty||end||endif||enum||eqv||event||exit||false||for||function||get||goto||if||imp||implements||in||integer||is||let||like||long||loop||lset||me||mod||new||next||not||nothing||null||on||option||optional||or||paramarray||preserve||private||public||raiseevent||redim||rem||resume||rows||rset||select||set||shared||single||size||static||stop||sub||then||to||true||type||typeof||until||variant||wend||while||with||xor|"
	if inStr(reserved_words,"|" & lcase(strValue) & "|") > 0 then
  is_reserved = true
	else
  is_reserved = false
	end if
end function

':: correct secure urls :::::::::::::::::::::::::::::::::::::::
': this section assures that user does not persist in
': ssl (https://) mode. only pages in the application
': secure_pages variable (global.asa) will stay in https.
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

if request.servervariables("https") = "on" then

': list of pages where https is permitted
secure_list = application("secure_pages")
this_page = request.servervariables("script_name")

a_tmp = split(secure_list, ",")
for ctr = 0 to uBound(a_tmp)
	if instr(this_page,trim(a_tmp(ctr))) > 0 then
  '' this page should be secure
  b_redirect = false
  exit for
	else
  b_redirect = true
	end if
next
if b_redirect then response.redirect "http://" & request.servervariables("server_name") & request.servervariables("script_name")

end if

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

%>
Apartir deste ele só manda as informaçoes depois de confirmar o global.asa:
<!-- place this file, or edit the exisiting "global.asa" file in the web site root folder -->

<object runat="server" scope="application" id="online_users" progid="scripting.dictionary"></object>

<script LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart

	':: app database connection string
	application("cn_str") = "provider=microsoft.jet.oledb.4.0;data source=" & server.MapPath("data/8681.mdb") & ""

	':: initilize application variables from database
	set cn = Server.CreateObject("ADODB.Connection")
	cn.Open application("cn_str")
	set rs = cn.Execute("SELECT * FROM AppSettings")
	for each field in rs.Fields
  application(field.Name) = field.Value
	next
  
End Sub

Sub Session_OnStart

	session.timeout = 20

End Sub

Sub Session_OnEnd

	if isObject(online_users) then
  on error resume next
  online_users.remove (session.sessionid)
	end if

End Sub

</SCRIPT>
Se tiver algum erro ele redireciona a página para o error.asp indicando o possivel erro:

Unable to connect to application database. This database is defined by the connection string located in the 'global.asa' file for this site. 
<br><br>
Possible causes:
<ol>
<li> The syntax of the connection string is incorrect
<li> A connection string attribute (ie; dsn, database, uid, pwd, etc..) is incorrect
<li> The database server is temporarily unavailable
<li> The 'global.asa' file must be located in the Web site (application) root (this may be separate from the other PortalApp files)
</ol>
<br><br>
Open the 'global.asa' file to verify the cn_str assignment.

<br><br><br>
<A href=''>Click here to retry</A>

É onde eu to ficando maluco que não acho o erro que ele aponta rss

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,6k
×
×
  • Criar Novo...