I'm trying to set up a form that checks an SQL database to make sure that the team_name = request.form("team_name") does not already exist in the DB. The form submits to itself, checks the value in the database and if the team_name value exists the form reloads with the values filled in from the previous submit <%=team_name%>. The values are not being picked up (i'm losing them when i connect to the database)

Here is the code to connect to the database, with a two response.redirect
1) if form not okay, response.redirect="http://somesite.com/Team_RegistrationERROR.asp"

2) if form okay,
Response.Redirect "http://somesite.com/Team_CCpayment.asp" --values carry over to this page.

The values for the fileds are being lost on the redirect.

Can someone please help me out with the below ASP code?

Connect to DB Code
Code:
<%
team_name = request.form("team_name")
capfname = Request.Form("cap_fname")
caplname = Request.Form("cap_lname")
address1 = Request.Form("address1")
address2 = Request.Form("address2")
city = Request.Form("city")
state = Request.Form("state")
zip = Request.Form("zip")
phone = Request.Form("phone")
email = Request.Form("email")
ataNum = Request.Form("ataNum")
ataAvg = Request.Form("ataAvg")
ataYard = Request.Form("ataYard")
%>
<%
team_name = request.form("team_name")
capfname = Request.Form("cap_fname")
caplname = Request.Form("cap_lname")
address1 = Request.Form("address1")
address2 = Request.Form("address2")
city = Request.Form("city")
state = Request.Form("state")
zip = Request.Form("zip")
phone = Request.Form("phone")
email = Request.Form("email")
ataNum = Request.Form("ataNum")
ataAvg = Request.Form("ataAvg")
ataYard = Request.Form("ataYard")
%>
<%
'if problem, continue without throwing error code
'take this out to receive debug msgs
'on error resume next
'Dim Connect to SQL Server Str
Dim connection, sSQL, sConnString, oRS, oConn
Dim connectstr, fieldname, tablename
Dim db_name, db_username, db_userpassword
Dim db_server
Dim checkConn,countrec,check_qry,check_connectstr,checkRS

'last chance to check for prop vals so strain off blank spaces in POST URL
team_name = left(Trim(Replace(Request.Form("team_name"),"'","''")),40)
capfname = left(Trim(Replace(Request.Form("cap_fname"),"'","''")),40)
caplname = left(Trim(Replace(Request.Form("cap_lname"),"'","''")),40)
address1 = left(Trim(Replace(Request.Form("address1"),"'","''")),40)
address2 = left(Trim(Replace(Request.Form("address2"),"'","''")),40)
city = left(Trim(Replace(Request.Form("city"),"'","''")),40)
state = left(Trim(Replace(Request.Form("state"),"'","''")),40)
zip = left(Trim(Replace(Request.Form("zip"),"'","''")),40)
phone = left(Trim(Replace(Request.Form("phone"),"'","''")),40)
email = left(Trim(Replace(Request.Form("email"),"'","''")),40)
ataNum = left(Trim(Replace(Request.Form("ataNum"),"'","''")),40)
ataAvg = left(Trim(Replace(Request.Form("ataAvg"),"'","''")),40)
ataYard = left(Trim(Replace(Request.Form("ataYard"),"'","''")),40)

if team_name <> "" THEN

	'check to see if e-mail ADDY is already there
	check_qry = "select * from teamtrap where ([team_name]) like ('" & _
	team_name & "')" 

	DBConnectionTwunk()
	check_connectstr = "Driver={SQL Server};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

Set checkConn = Server.CreateObject("ADODB.Connection")
	checkConn.Open check_connectstr
	countrec=0
	Set checkRS = checkConn.Execute(check_qry)
	if not checkRS.EOF then
		while not checkRS.EOF
			countrec=countrec+1
			checkRS.movenext
		wend
		checkRS.close
	end if
	Set checkRs = nothing
	Set checkConn = nothing

	if countrec > 0 then			
			'If Rec Found then Throw Dupe E-Mail Error Page

			Response.Redirect "http://somesite.com/Team_RegistrationERROR.asp" 

else
	'Else Throw Error Pg if Prob
	Response.Redirect "http://somesite.com/Team_CCpayment.asp"
end if
end if
	

Function DBConnectionTwunk()
'Routine makes SQLServer DB Conn
	db_server = "somesite.net"
	db_name = "DB_name"
	db_username = "username"
	db_userpassword = "12345"
	fieldname = "fieldname"
	tablename = "tablename"
End Function
%>

FORM Code, autofilled with values. The values should carry over to the CC_Payment Page
Code:
<form action="Team_RegistrationERROR.asp" method="post" name="formname" id="formname" onsubmit="return checksubmit()">

                        <input name="team_name" type="hidden" id="team_name" value="<%=team_name%>" />
                       
              </form>