Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asptoday_discuss thread: trouble submitting data to Access DB


Message #1 by "Dave Burdick" <burdickdave@h...> on Wed, 19 Jun 2002 08:11:10
I'm somewhat new to ASP, but have a good understanding of it from VB 
experience.  I was currently attempting to submit a form to an Access DB; 
the form data submitted to one table but not to another.  Both tables were 
opened with the statement:

objRS.Open "tablename", strConnect, adOpenStatic, adLockOptimistic, 
adCmdTable

the first table titled "User" produced an error saying that the objRS.Open 
line produced an error in the FROM clause, which confused me since the 
same line of code is used and executed correctly to open the "Company" 
table.  Also, there are no FROM SQL statements in my code.

Here is the excerpt of ASP code associated with this error:



 <%
          If (Request.Form("txtFirstName") <> "") And (Request.Form
("txtLastName") <> "") And (Request.Form("txtCompanyName") <> "") And 
(Request.Form("txtCity") <> "") Then
          
          Dim objRS
          Dim contactadd, firstnameadd, lastnameadd, companynameadd, 
streetadd, street2add, cityadd, stateadd, countryadd, zipcodeadd, poboxadd
          Dim workareaadd, workpreadd, worksuffadd, homeareaadd, 
homepreadd, homesuffadd, faxareaadd, faxpreadd, faxsuffadd, emailadd 
          
          contactadd = Request.Form("optContact")
          firstnameadd = Request.Form("txtFirstName")
          lastnameadd = Request.Form("txtLastName")
          companynameadd = Request.Form("txtCompanyName")
          streetadd = Request.Form("txtStreet")
          street2add = Request.Form("txtStreet2")
          cityadd = Request.Form("txtCity")
          stateadd = Request.Form("cboStates")
          countryadd = Request.Form("txtCountry")
          zipcodeadd = Request.Form("txtZipCode")
          poboxadd = Request.Form("txtPOBox")
          workareaadd = Request.Form("txtWorkPhoneArea")
          workpreadd = Request.Form("txtWorkPhonePre")
          worksuffadd = Request.Form("txtWorkPhoneSuff")
          homeareaadd = Request.Form("txtHomePhoneArea")
          homepreadd = Request.Form("txtHomePhonePre")
          homesuffadd = Request.Form("txtHomePhoneSuff")
          faxareaadd = Request.Form("txtFaxArea")
          faxpreadd = Request.Form("txtFaxPre")
          faxsuffadd = Request.Form("txtFaxSuff")
          emailadd = Request.Form("txtEmail")
          
          Set objRS = Server.CreateObject("ADODB.Recordset")
      
          objRS.Open "User", strConnect, adOpenStatic, adLockOptimistic, 
adCmdTable
          
		  objRS.AddNew
		  	objRS("username") = firstnameadd & lastnameadd & 
companynameadd
		  	objRS("firstname") = firstnameadd
		  	objRS("lastname") = lastnameadd
		  	objRS("companyid") = companynameadd & cityadd
		  	If (workpreadd <> "") And (worksuffadd <> "") Then
		  		If (workareaadd <> "") Then
		  			objRS("workphone") = workareaadd & 
workpreadd & worksuffadd
		  		ElseIf (workareaadd = "") Then
		  			objRS("workphone") = "000" & 
workpreadd & worksuffadd
		  		End If
		  	End If
		  	If (faxpreadd <> "") And (faxsuffadd <> "") Then
		  		If (faxareaadd <> "") Then
		  			objRS("fax") = faxareaadd & 
faxpreadd & faxsuffadd
		  		ElseIf (faxareaadd = "") Then
		  			objRS("fax") = "000" & faxpreadd & 
faxsuffadd
		  		End If
		  	End If
		  	If (homepreadd <> "") And (homesuffadd <> "") Then
		  		If (homeareaadd <> "") Then
		  			objRS("homephone") = homeareaadd & 
homepreadd & homesuffadd
		  		ElseIf (homeareaadd = "") Then
		  			objRS("homephone") = "000" & 
homepreadd & homesuffadd
		  		End If
		  	End If
		  	objRS("visitdate") = Date()
		  	objRS("visittime") = Time()
          	objRS("contact") = contactadd
          	objRS.Update
          	objRS.Close

          objRS.Open "Company", strConnect, adOpenStatic, 
adLockOptimistic, adCmdTable

          objRS.AddNew
          	objRS("companyid") = companynameadd & cityadd
          	objRS("companyname") = companynameadd
          	If streetadd <> "" Then
          		objRS("street") = streetadd
          	End If
          	If street2add <> "" Then
          		objRS("ste") = street2add
          	End If
          	objRS("city") = cityadd
          	If stateadd <> "" Then
          		objRS("state") = stateadd
          	End If
          	If zipcodeadd <> "" Then
          		objRS("zip") = zipcodeadd
          	End If
          	If poboxadd <> "" Then
          		objRS("pobox") = poboxadd
          	End If
          objRS.Update
          objRS.Close

          %>

  Return to Index