connection.Open causing error on page where form i

Results 1 to 2 of 2

Thread: connection.Open causing error on page where form i

  1. #1
    Join Date
    Dec 1969

    Default connection.Open causing error on page where form i

    I have a page with a form containg some drop down lists. The values in these lists are read in from a table in a database. After the last read and &#039;do while&#039; loop to populate my list I close all connection. Then when the user clicks submits, I do client side validation with javascript and submit the form to another page where I open the database connection again and input the values from the form into another table in the db. I inlcude the database connection file as <BR>&#060;!--#include file="connection.asp"--&#062;<BR>in both pages and the file is<BR>&#060;%<BR>dim objConn<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .ConnectionString = "DRIVER={Microsoft Access Driver (*.Mdb)};DBQ=C:TEMPsocialClub.mdb"<BR>objConn.Open <BR>%&#062;<BR><BR>But when it reaches objConn.Open on the 2nd page the form is submitted to it gives me an error.<BR>Any ideas??? And thanks for all help!

  2. #2
    Join Date
    Dec 1969

    Default RE: try this

    You may want to check if the connection is already open:<BR><BR>Sub DBConnect ()<BR><BR>On Error Resume Next<BR> <BR>&#039;ADO Connection Object<BR>Set oDBConn = Server.CreateObject("ADODB.Connection")<BR><BR>&#0 39;Don&#039;t open DB connection again if already opened!<BR>If Not oDBConn.State &#060;&#062; adStateOpen Then <BR><BR>&#039;Open Connection<BR>oDBConn.Open( sConnectionString )<BR> <BR>End If<BR><BR>End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts