Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Connection not closing

Status
Not open for further replies.

debbierich22

Programmer
Sep 25, 2001
13
0
0
US
I have a page that registers users on my website. Once they have entered information into textboxes and clicked the submit button, they are redirected to a generic page that contains only HTML to say they have successfully registered.

I am using a DSN to connect to an Access database, and I know this is configured correctly because the transaction will succeed one time. I have included code to close the connection but when I navigate to any other page in my website that has a database connection, I receive an error on the line where I open the new connection to the same database. The error is either "Unspecified Error" or "Microsoft OLEDB error:file is already in use." This happens throughout my site and I am using the same method to close the connection throughout (which I think is my problem.)

Check out the example below:

Code:
<%
dim Uname,Pword,Email,Name
Uname = Request(&quot;Username&quot;)
Pword = Request(&quot;Password&quot;)
Email = Request(&quot;Email&quot;)
Name = Request(&quot;Name&quot;)

IF Uname <> &quot;&quot; AND Pword <> &quot;&quot; AND Email<> &quot;&quot; AND Name <> &quot;&quot; THEN
	'Connect to database
	Dim Conne, sourceDSN, strSQL, Results
	sourceDSN=&quot;utilreport&quot;
	Set Conne = Server.CreateObject(&quot;ADODB.Connection&quot;)
	Conne.Open sourceDSN

	strSQL = &quot;INSERT INTO Users(User_Id,Password,Name,Email) VALUES('&quot; + Uname + &quot;','&quot; + Pword + &quot;','&quot; + Name + &quot;','&quot; + Email + &quot;')&quot;
	Conne.Execute(strSQL)
	Conne.Close
        Set Conne = Nothing
	Response.redirect(&quot;registersuccess.asp&quot;)
END IF
%>
<h1>Registration</h1>
<form method=post action=&quot;register.asp&quot;>
<br>
<TABLE>
<TR valign=top>
	<TD><h3>Username:</h3></TD>
	<TD><INPUT MAXLENGTH=20 NAME=&quot;Username&quot; SIZE=25></TD>
</TR>
<TR valign=top>
	<TD><h3>Password:</h3></TD>
	<TD><INPUT type=password MAXLENGTH=20 NAME=&quot;Password&quot; SIZE=25></TD>
</TR>
<TR valign=top>
	<TD><h3>Name:</h3></TD>
	<TD><INPUT MAXLENGTH=20 NAME=&quot;Name&quot; SIZE=25></TD>
</TR>
<TR valign=top>
	<TD><h3>E-Mail Address:</h3></TD>
	<TD><INPUT MAXLENGTH=50 NAME=&quot;Email&quot; SIZE=50></TD>
</TR>
<TR valign=top>
	<TD colspan=2><center><h3>* All fields are required.</h3><center></TD>
</TR>
<TR valign=top>
	<TD colspan=2><center><INPUT Type=Submit NAME=&quot;Submit&quot; Value=&quot;Submit&quot;></center></TD>
</TR>
</TABLE>
</form>

When I return to this same page, I cannot access the database. If I close the browser and relaunch the browser, this does not resolve the problem. Re-starting the entire computer seems to be the only solution. HELP!
 
Just to be clear, when I return to this page the line where I get the error is:

&quot;Conne.Open sourceDSN&quot;

 
Bob, Thanks for the reply. I'm currently trying that idea now, although I have only done this with DSNs, so it's kind of slow going. Before I started down that road I tried &quot;Response.Write(Conne)&quot; and that came out with the correct connection string. Any suggestions on how best to create the connection without a DSN?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top