Muitos programadores utilizam include para abrir a conexão com o banco de dados, porém o ODP apresenta erro dizendo que a conexão não foi fechada e o objeto não foi destruido, mesmo fechando a conexão e destruindo o objeto no final do arquivo onde está o include.
Criando função para abri conexão
Nesses casos devemos criar uma função para abrir a conexão passando os parâmetros da mesma e uma sub para fechá-la, como o exemplo abaixo (vamos chamá-lo de db.asp):
<% function abre_conexao(ConnString,conexao) ConnString="Provider=SQLOLEDB.1;SERVER=HM87;DATABASE=nomedabase;UID=login;PWD=senha;" set conexao=server.createobject("adodb.connection") conexao.open ConnString end function sub fecha_conexao() conexao.close set conexao = nothing end sub %>
Na página onde será feita a conexão, coloque o include:
<!--#INCLUDE file="db.asp" -->
Para abrir a conexão basta chamar a sub:
Call abre_conexao(ConnString,conexao)
e para fechá-la chamar a sub:
Call fecha_conexao()
OBS: O código de programação mencionado neste artigo é uma sugestão. Contamos com sua compreensão para o fato de que a Locaweb não pode se responsabilizar por apresentar mais detalhes a respeito de sua implementação e utilização. Para mais informações, sugerimos que entre em contato com o seu desenvolvedor, pois tal conhecimento é aberto e de domínio de profissionais técnicos. Caso queira entrar em contato conosco a respeito deste tema, orientamos a abrir um chamado via HelpDesk.
Veja também
- Protegendo seus formulários de contato em Asp
- Erros comuns em ASP
- O que é e como faço para acessar o Gerenciador de ODP
SQL Server
SQL Server Native Client 10.0 OLE DB Provider
Segurança Padrão
Provider=SQLNCLI10;Server=EnderecoDoServidor;Database=NomeDaBaseDeDados;Uid=UsuarioSQL; Pwd=SenhaSQL;
Database mirroring
Se sua aplicação acessa uma base de dados via ADO.NET ou SQL Native Client, você pode configurar para que o driver redirecione a conexão para o servidor com a base de dados Principal automaticamente em caso de failover. Você precisa informar o servidor principal e o servidor parceiro na string de conexão:
Provider=SQLNCLI10;Data Source=EnderecoDoServidor;Failover Partner=EnderecoDoServidorMirror; Initial Catalog=NomeDaBaseDeDados;User Id=UsuarioSQL;Password=SenhaSQL;
SQL Server Native Client 10.0 ODBC Driver
Segurança Padrão
Driver={SQL Server Native Client 10.0};Server=EnderecoDoServidor;Database=NomeDaBaseDeDados; Uid=UsuarioSQL;Pwd=SenhaSQL;
Database mirroring
Se sua aplicação acessa uma base de dados via ADO.NET ou SQL Native Client, você pode configurar para que o driver redirecione a conexão para o servidor com a base de dados Principal automaticamente em caso de failover. Você precisa informar o servidor principal e o servidor parceiro na string de conexão:
Driver={SQL Server Native Client 10.0};Server=EnderecoDoServidor;Database=NomeDaBaseDeDados; Failover_Partner=EnderecoDoServidorMirror;Uid=UsuarioSQL;Pwd=SenhaSQL;
SQL Native Client 9.0 OLE DB provider
Segurança Padrão
Provider=SQLNCLI;Server=EnderecoDoServidor;Database=NomeDaBaseDeDados; Uid=UsuarioSQL; Pwd=SenhaSQL;
Database mirroring
Se sua aplicação acessa uma base de dados via ADO.NET ou SQL Native Client, você pode configurar para que o driver redirecione a conexão para o servidor com a base de dados Principal automaticamente em caso de failover. Você precisa informar o servidor principal e o servidor parceiro na string de conexão:
Provider=SQLNCLI;Data Source=EnderecoDoServidor;Initial Catalog=NomeDaBaseDeDados; Failover Partner=EnderecoDoServidorMirror;User Id=UsuarioSQL;Password=SenhaSQL;
SQL Native Client 9.0 ODBC Driver
Segurança Padrão
Driver={SQL Server Native Client};Server=EnderecoDoServidor;Database=NomeDaBaseDeDados; Uid=UsuarioSQL;Pwd=SenhaSQL;
Database mirroring
Se sua aplicação acessa uma base de dados via ADO.NET ou SQL Native Client, você pode configurar para que o driver redirecione a conexão para o servidor com a base de dados Principal automaticamente em caso de failover. Você precisa informar o servidor principal e o servidor parceiro na string de conexão:
Driver={SQL Server Native Client};Server=EnderecoDoServidor;Database=NomeDaBaseDeDados; Failover_Partner=EnderecoDoServidorMirror;Uid=UsuarioSQL;Pwd=SenhaSQL;
.NET Framework Data Provider for SQL Server
Segurança Padrão
Data Source=EnderecoDoServidor;Initial Catalog=NomeDaBaseDeDados;User Id=UsuarioSQL;Password=SenhaSQL;
Database mirroring
Se sua aplicação acessa uma base de dados via ADO.NET ou SQL Native Client, você pode configurar para que o driver redirecione a conexão para o servidor com a base de dados Principal automaticamente em caso de failover. Você precisa informar o servidor principal e o servidor parceiro na string de conexão:
Data Source=EnderecoDoServidor;Initial Catalog=NomeDaBaseDeDados; Failover Partner=EnderecoDoServidorMirror;User Id=UsuarioSQL;Password=SenhaSQL;
Microsoft SQL Server OLE DB Provider
Segurança Padrão
Provider=sqloledb;Data Source=EnderecoDoServidor;Initial Catalog=NomeDaBaseDeDados; User Id=UsuarioSQL;Password=SenhaSQL;
Microsoft SQL Server ODBC Driver
Segurança Padrão
Driver={SQL Server};Server=EnderecoDoServidor;Initial Catalog=NomeDaBaseDeDados; User Id=UsuarioSQL;Password=SenhaSQL;
MySQL
MySQL Connector/ODBC 5.1
Segurança Padrão
Driver={MySQL ODBC 5.1 Driver};Server=EnderecoDoServidor;Port=3306;Database=NomeDaBaseDeDados; User=UsuarioSQL; Password=SenhaSQL;Option=3;
MySQL Connector/Net
Segurança Padrão
Server=EnderecoDoServidor;Database=NomeDaBaseDeDados;Uid=UsuarioMySQL;Pwd=SenhaMySQL;Port=3306;
PostgreSQL
PostgreSQL ANSI
Driver={PostgreSQL ANSI};Server=EnderecoDoServidor;Port=5432;Database=NomeDaBaseDeDados;Uid=UsuarioSQL;Pwd=SenhaSQL;
PostgreSQL UNICODE
Driver={PostgreSQL UNICODE};Server=EnderecoDoServidor;Port=5432;Database=NomeDaBaseDeDados;Uid=UsuarioSQL;Pwd=SenhaSQL;
Referências
Oracle
Oracle Provider for OLE DB
TNS-less connection string
Provider=OraOLEDB.Oracle.1;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=EnderecoDoServidor)(PORT=PortaDoServidor)))(CONNECT_DATA=(SID=SIDdoOracle)(SERVER=DEDICATED))); User Id=UsuarioOracle;Password=SenhaOracle;
MS Access
ACE OLEDB 12.0
Segurança Padrão
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:/home/LOGIN_DE_FTP/dados/bancoAccess.accdb; Persist Security Info=False;
ACE OLEDB 12.0
Utilizando Senha
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:/home/LOGIN_DE_FTP/dados/bancoAccess.accdb; Jet OLEDB:NOME_DO_BANCO Password=SENHA_DO_BANCO;
Microsoft Jet OLE DB 4.0
Segurança Padrão
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:/home/LOGIN_DE_FTP/dados/bancoAccess.mdb;
Veja também
Your ability to enrapture readers is remarkable Gigantic post.
You’re doing adept work This post is stay of that
Amazing post You covered this theme perfectly onlinecasinogit.com/.
I’m in awe of your knack with a view writing This was brilliant.
Your insights are invaluable In fact conscious of your work.
Your ability to captivate readers is remarkable Enormous post
I simply got here throughout your post and turned into promptly captivated by way of your insights. Your perspective fish for is both uncomplicated and concept-provoking. it is manifest that you’ve achieved pretentiously delve into, and your province to introduce the facts in an attracting means is wonderful. this is a subject i’ve been interested in after a while, and your post has provided me with a brand new outlook. thanks for sharing your https://cialisbov.com/.
trainer porn
Nice article inspiring thanks. Hello Administ .
Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across.
Yer altı sığınak için uygun fiyatlı tekyıldız inşaat için bizimle iletişime geçin.
Yer altı sığınak için uygun fiyatlı tekyıldız inşaat için bizimle iletişime geçin.
Good info. Lucky me I reach on your website by accident, I bookmarked it.
Good info. Lucky me I reach on your website by accident, I bookmarked it.
Beyaz Eşya Servisi: Birçok beyaz eşya servisi bulunmaktadır. Ancak, güvenilir ve kaliteli hizmet sunan birini seçmek önemlidir. Beyaz eşya servisi konusunda uzmanlaşmış birkaç firma bulunmaktadır. Bu firmalar, deneyimli teknisyenlerle donatılmıştır ve çeşitli marka ve modellerdeki beyaz eşyalarınızın tamiri ve bakımı konusunda uzmanlaşmışlardır.
hijab porn fling trainer
nice article
Bahis sitelerine giriş yapmak istediğinizde sitelerin şartlarını ve kurallarını incelemeniz önerilecektir.
Wow that was strange. I just wrote an really long comment but after I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say great blog!
Wonderful site. Plenty of useful information here. I’m sending it to several friends ans additionally sharing in delicious. And of course, thank you on your sweat!
I was suggested this website by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my difficulty. You are wonderful! Thanks!
It is appropriate time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I desire to suggest you few interesting things or advice. Maybe you can write next articles referring to this article. I desire to read even more things about it!
hello there and thank you for your info – I have definitely picked up something new from right here. I did however expertise a few technical issues using this site, since I experienced to reload the web site lots of times previous to I could get it to load correctly. I had been wondering if your web hosting is OK? Not that I’m complaining, but sluggish loading instances times will very frequently affect your placement in google and can damage your high quality score if ads and marketing with Adwords. Anyway I am adding this RSS to my e-mail and could look out for much more of your respective fascinating content. Make sure you update this again very soon..
Good day! This post couldn’t be written any better! Reading through this post reminds me of my old room mate! He always kept talking about this. I will forward this write-up to him. Pretty sure he will have a good read. Many thanks for sharing!
Hi there! Would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would really enjoy your content. Please let me know. Thanks
Hey very cool site!! Man .. Beautiful .. Amazing .. I’ll bookmark your blog and take the feeds also…I’m happy to find numerous useful information here in the post, we need develop more strategies in this regard, thanks for sharing. . . . . .
Hey very cool site!! Man .. Beautiful .. Amazing .. I will bookmark your web site and take the feeds also…I’m happy to find so many useful information here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . .
Vansales.com Click here
was such an interesting read!
You completed a number of nice points there. I did a search on the issue and found nearly all people will have the same opinion with your blog.betflik
Hey There. I found your blog using msn. This is a really well written article. I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I will certainly return.
When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four e-mails with the same comment. Is there any way you can remove people from that service? Thank you!
very awesome post
You completed a number of nice points there. I did a search on the issue and found nearly all people will have the same opinion with your blog.betflik
Hi! Do you use Twitter? I’d like to follow you if that would be ok. I’m absolutely enjoying your blog and look forward to new posts.
great article!