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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assistance with getting values into DB

Status
Not open for further replies.

rjn2001

Programmer
Dec 29, 2004
172
GB
This code, I am using to add project details into a DB, the only thing is, is that it aint getting written to the DB!,..could anyone please assist?

Code:
<!--#include file="security.asp" -->
<%

'File: PrivatePageProject.asp
'Description: Authorised Page

'set conn=Server.CreateObject("ADODB.Connection")
'conn.Provider="Microsoft.Jet.OLEDB.4.0"
'conn.Open "D:/Websites/richard/admin/db/users.mdb"

for xx=1 to Request("ProjectStart").Count
 for y=1 to Request("ProjectFinish").Count
  for z=1 to Request("OrganisationName").Count
   for jb=1 to Request("ProjectRole").Count
    for jd=1 to Request("ProjectDetails").Count

if xx=y Then
 if xx=z Then
  if xx=jb Then
   if xx=jd Then

'Response.Write Request("ProjectStart").Item(xx) & Request("ProjectFinish").Item(y) & Request("OrganisationName").Item(z) & Request("ProjectRole").Item(z) & Request("ProjectDetails").Item(z) & "<br />"
'Response.Write(strUserName)



strSQL = "INSERT into tblProject (ProjectStart, ProjectFinish, OrganisationName, ProjectRole, ProjectDetail, UserName) values ('" &  Request("ProjectStart").Item(xx) & "', '" & Request("ProjectFinish").Item(y) & "', '" & Request("OrganisationName").Item(z) & "', '" & Request("ProjectRole").Item(z) & "', '" & Request("ProjectDetails").Item(z) & "', '" & strUserName & "') " 
'Response.Write(strSQL)
conn.Execute strSQL
   End If
  End If
 End If
End If

'response.write("ProjectStart #" &xx& " is " & Request("ProjectStart").Item(xx) & "<br />")
'response.write("ProjectFinish #" &y& " is " & Request("ProjectFinish").Item(y) & "<br />")
 
   next
   next
  next
 next
next

'Response.Write("Database has been updated")
'Response.Write(strSQL)
'conn.close

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "D:/Websites/richard/admin/db/users.mdb"
	
	'Build connection
	'strSQL="insert into tblUsers ([UserID], First_Name, Last_Name, [Password], Sec_ques, Ethnicity, Sec_Ans, Birth_Year, Address, Post_Code, e_mail, www, Gender, County, Country, Nationality, Required, OtherPermit, DistributionLogistics, ManOps, StratDev, AccountCon, CorpFin, ITDeploy, ITDesign, ITOther, Marketing, HumanResources, Sales, Purchasing, Automotive, ECommerce, Energy, FinServices, ITIndustry, LeisureIndustry, HealthIndustry, ManufacturingEngineering, NotForProfit, Publishing, Retail, TeleComs, TransportationIndustry, UtilityIndustry, Other) values ('" & UserID& "', '" & First_Name& "', '" & Last_Name& "', '" & Password& "' , '" & Sec_ques& "', '" & Sec_Ans& "', '" & Birth_Year& "', '" & Address& "', '" & Post_Code& "', '" & e_mail& "', '" & www& "', '" & Gender& "', '" &County & "', '" &Country & "', '" &Nationality & "','" &Required & "','" & OtherPermit& "','" & DistributionLogistics& "','" & ManOps& "','" & StratDev& "','" & AccountCon& "','" & CorpFin& "','" & ITDeploy& "','" & ITDesign& "','" &'ITOther& "','" & Marketing& "','" & HumanResources& "','" & Sales& "','" & Purchasing& "','" & Automotive& "','" & ECommerce& "','" & Energy& "','" & FinServices& "','" & ITIndustry& "','" & LeisureIndustry& "','" & HealthIndustry& "','" & ManufacturingEngineering& "','" & NotForProfit& "','" & Publishing& "','" & Retail& "','" & TeleComs& "','" & TransportationIndustry& "','" & UtilityIndustry& "','" & Ethnicity& "','" & Other& "');"

	response.write(strSQL)
	'conn.Execute strSQL
'conn.Execute sql,recaffected

conn.close

%>

Richard Noon
 
you have a lot of code commented out in your example above - have you tried the code with the comments removed?


Tony
_______________________________________________________________
 
Which insert statement is giving you problems...Everywhere i see only the commented code...

clean it up and try one insert statement at a time

-SecondToNone
 
Also - assuming your logic is correct, this...
Code:
if xx=y Then
 if xx=z Then
  if xx=jb Then
   if xx=jd Then
can be changed to this...
Code:
If xx=y AND xx=z AND xx=jb AND xx=jd Then

Tony
_______________________________________________________________
 
well, I am using exactly the same code in project.asp as I am in job.asp, except the SQL code has been changed to reflect this, also, so have all the file names etc, the job page works a treat, just this page dont send the data anywhere!

i will try removing the commas, see what happens......



Richard Noon
 
Right, I am not getting any errors, the page just basically refreshes itself. I have removed the abandoned code, and this is what I am left with. The response.write(strSQl) dont work, nothing is displayed.

Code:
<%

'File: authorised.asp
'Description: Authorised Page


set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "D:/Websites/richard/admin/db/users.mdb"

for xx=1 to Request("ProjectStart").Count
 for y=1 to Request("ProjectFinish").Count
  for z=1 to Request("OrganisationName").Count
   for jb=1 to Request("ProjectRole").Count
    for jd=1 to Request("ProjectDetail").Count



if xx=y Then
 if xx=z Then
  if xx=jb Then
   if xx=jd Then

strSQL = "insert into tblProject(ProjectStart, ProjectFinish, OrganisationName, ProjectRole, ProjectDetail, UserID) values ('" &  Request("ProjectStart").Item(xx) & "', '" & Request("ProjectFinish").Item(y) & "', '" & Request("OrganisationName").Item(z) & "', '" & Request("ProjectRole").Item(z) & "', '" & Request("ProjectDetail").Item(z) & "', '" & strUserName & "') " 
Response.Write(strSQL)
conn.Execute strSQL

   End If
  End If
 End If
End If

 
   next
   next
  next
 next
next

conn.close
	
%>

Richard Noon
 
what form values are you getting back in ProjectStart, ProjectFinish, OrganisationName, etc...??

For example, what gets displayed when you do this at the top of your page
Code:
For Each item in Request.Form
  Response.Write item & ": " & Request.Form(item)
Next

Response.End

Tony
_______________________________________________________________
 
Hi, this is the page of code that works, it adds job experience, and submits all the data to the DB, this is privatepagejob.asp. FULLY WORKING
*********There is alot of code to follow!!***********
Code:
<!--#include file="security.asp" -->
<%

'File: authorised.asp
'Description: Authorised Page


set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "D:/Websites/richard/admin/db/users.mdb"

for xx=1 to Request("JobStart").Count
 for y=1 to Request("JobFinish").Count
  for z=1 to Request("EmployerName").Count
   for jb=1 to Request("JobRole").Count
    for jd=1 to Request("JobDetail").Count



if xx=y Then
 if xx=z Then
  if xx=jb Then
   if xx=jd Then

strSQL = "insert into tblJob (JobStart, JobFinish, EmployerName, JobRole, JobDetail, UserID) values ('" &  Request("JobStart").Item(xx) & "', '" & Request("JobFinish").Item(y) & "', '" & Request("EmployerName").Item(z) & "', '" & Request("JobRole").Item(z) & "', '" & Request("JobDetail").Item(z) & "', '" & strUserName & "') " 
Response.Write(strSQL)
conn.Execute strSQL
   End If
  End If
 End If
End If

 
   next
   next
  next
 next
next

conn.close
	
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML dir=ltr xmlns-asp="null" xmlns-shell="null"><HEAD>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="copyright" content="Copyright (C) 2005 Blue Alumni Resourcing">
<META content=en-us name=MS.LOCALE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="BLue Alumni Resourcing 2005" name=keywords>
<link rel="stylesheet" type="text/css" href="css.css">
<META content="<%= Date() %>" name=last-updated>
<title><%= strUsername %>, User Panel</title>
</head>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" link="#3366CC" vlink="#008000" alink="#FF0000">

		<H1><img border="0" src="images/BARLogo.gif" width="125" height="110"> 
        Edit your Job Experiences</H1>
<p align="center" style="margin-top: -1px; margin-bottom: -1px">
		&nbsp;</p>
		<table border="0" width="100%" id="table1">
			<tr>
				<td>
		<h3>Today:&nbsp;<b><%= Date() %></b> ,Welcome&nbsp;<b><%= rsCheckUser("First_Name") %>&nbsp;<%= rsCheckUser("Last_Name") %>&nbsp;(Login as: <%= strUserName %>)</b>, to 
		<%= strWebsiteName %></h3></td>
			</tr>
			<table border="0" cellspacing="2" style="border-collapse: collapse" bordercolor="#111111" width="873" id="AutoNumber1" height="26">
  <tr>
    <td width="385" bgcolor="#5C5CA8" height="1" bordercolor="#0099CC">
      <p align="left"><font color="#FFFFFF"><b>Job Experience</b></font></p>
    </td>
  </tr>
  <tr>
    <td width="385" bgcolor="#0099CC" height="1" bordercolor="#5C5CA8">
      <p align="right">
<input type=button value="Add Another Job Experience" onClick="addRow()" name="AddJobExp">


    </td>
  </tr>
  </table>
  <table border="2" bordercolor="#5C5CA8" width="869" height="66">
<table BORDER=1 height="44">
<form name="test" method="post" action="privatepagejob.asp?.rand=<%= Md5Hash %>">
    <tr id=baseRow>
        <td height="38">Start Date
          <p><input name="JobStart" size="8"></p>
        </td>
        <td height="38">End Date
          <p><input name="JobFinish" size="8"></p>
        </td>
        <td height="38">Organisation Name
          <p><input name="EmployerName" size="25"></p>
        </td>
        <td height="38">Your Role
          <p><textarea rows="3" name="JobRole" cols="23"></textarea></p>
        </td>
        <td height="38">More Detail
          <p><textarea rows="3" name="JobDetail" cols="22"></textarea></p>
        </td>
        <td height="38">
          <p align="center">Not Deletable</p>
        </td>
    </tr>
</table>
&nbsp;
<p align="right">&nbsp;


<script language=javascript>
    rowCount = 1
    function addRow(){
        rowCount ++
        newRow = document.getElementById("baseRow").cloneNode(true)
        newRow.childNodes[0].childNodes[1].name = "JobStart" + rowCount    //first input in first cell
        newRow.childNodes[0].childNodes[1].value = ""
        newRow.childNodes[1].childNodes[1].name = "JobFinish" + rowCount    //first input in second cell
        newRow.childNodes[1].childNodes[1].value = ""
        newRow.childNodes[2].childNodes[1].name = "EmployerName" + rowCount    //first input in third cell
        newRow.childNodes[2].childNodes[1].value = ""
        newRow.childNodes[3].childNodes[1].name = "JobRole" + rowCount    //first input in fourth cell
        newRow.childNodes[3].childNodes[1].value = ""
        newRow.childNodes[4].childNodes[1].name = "JobDetail" + rowCount    //first input in fifth cell
        newRow.childNodes[4].childNodes[1].value = ""
        newRow.id = "row" + rowCount
        newButton = document.createElement("input")
        newButton.id = "button" + rowCount
        newButton.type = "button"
        newButton.value = "Delete"
        newButton.attachEvent("onclick", deleteRow)
        newRow.childNodes[5].childNodes[0].replaceNode(newButton) 
        
        document.getElementById("baseRow").parentNode.appendChild(newRow)
    }
    
    function deleteRow(){
        buttonID = event.srcElement.id        // ie - "button2"
        rowID = buttonID.substr(6)            // ie - "2"
        document.getElementById("row" + rowID).removeNode(true)
    }
</script>
<input type="submit" value="Submit &gt;&gt;"> 
<input type="button" value="Disagree &amp; Back" onClick="history.go(-1)">  </p>
<p align="center">&nbsp;&nbsp;&nbsp; <input type="reset" value=" Reset "></p>
<input type="hidden" name="cryptKey" value="<%= strSecurityKey %>">
</form>
			
		</table>
		<!-- #include file="footer.asp" -->		
</body>
<%
 'Close Objects
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing
%>

This is the page for adding project experience, this page cant submit to the DB, and the response.write(strSQl) dont write anything on the page, there are no error codes or anything, the page just refreshes itself. The two pages are more or less identical, the DB is setup correctly, the field names etc are all as they should be, and called what they should be, can anyone help?!!?!?!?!?!?!?!

Code:
<!--#include file="security.asp" -->
<%
'File: authorised.asp
'Description: Authorised Page


set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "D:/Websites/richard/admin/db/users.mdb"

for xx=1 to Request("ProjectStart").Count
 for y=1 to Request("ProjectFinish").Count
  for z=1 to Request("OrganisationName").Count
   for jb=1 to Request("ProjectRole").Count
    for jd=1 to Request("ProjectDetail").Count



if xx=y Then
 if xx=z Then
  if xx=jb Then
   if xx=jd Then

strSQL = "INSERT into tblProject (ProjectStart, ProjectFinish, OrganisationName, ProjectRole, ProjectDetail, UserID) values ('" &  Request("ProjectStart").Item(xx) & "', '" & Request("ProjectFinish").Item(y) & "', '" & Request("OrganisationName").Item(z) & "', '" & Request("ProjectRole").Item(z) & "', '" & Request("ProjectDetail").Item(z) & "', '" & strUserName & "') " 
Response.Write(strSQL)
conn.Execute strSQL

   End If
  End If
 End If
End If

 
   next
   next
  next
 next
next

conn.close
	
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML dir=ltr xmlns-asp="null" xmlns-shell="null"><HEAD>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="copyright" content="Copyright (C) 2005 Blue Resourcing">
<META content=en-us name=MS.LOCALE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="Blue Resourcing" name=keywords>
<link rel="stylesheet" type="text/css" href="css.css">
<META content="<%= Date() %>" name=last-updated>
<title><%= strUsername %>, Project Panel</title>
</head>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" link="#3366CC" vlink="#008000" alink="#FF0000">

		<H1><img border="0" src="images/BARLogo.gif" width="125" height="110"> 
        Edit your Project Experiences</H1>
<p align="center" style="margin-top: -1px; margin-bottom: -1px">
		&nbsp;</p>
		<table border="0" width="100%" id="table1">
			<tr>
				<td>
		<h3>Today:&nbsp;<b><%= Date() %></b> ,Welcome&nbsp;<b><%= rsCheckUser("First_Name") %>&nbsp;<%= rsCheckUser("Last_Name") %>&nbsp;(Login as: <%= strUserName %>)</b>, to 
		<%= strWebsiteName %></h3></td>
			</tr>
			<table border="0" cellspacing="2" style="border-collapse: collapse" bordercolor="#111111" width="873" id="AutoNumber1" height="26">
  <tr>
    <td width="385" bgcolor="#5C5CA8" height="1" bordercolor="#0099CC">
      <p align="left"><font color="#FFFFFF"><b>Project Experience</b></font></p>
    </td>
  </tr>
  <tr>
    <td width="385" bgcolor="#0099CC" height="1" bordercolor="#5C5CA8">
      <p align="right">
<input type=button value="Add Another Project Experience" onClick="addRow()" name="AddProject">


    </td>
  </tr>
  </table>
  <table border="2" bordercolor="#5C5CA8" width="869" height="66">
<table BORDER=1 height="44">
<form name="test" method="post" action="privatepageproject.asp?.rand=<%= Md5Hash %>">
    <tr id=baseRow>
        <td height="38">Start Date
          <p><input name="ProjectStart" size="8"></p>
        </td>
        <td height="38">End Date
          <p><input name="ProjectFinish" size="8"></p>
        </td>
        <td height="38">Organisation Name
          <p><input name="OrganiationName" size="25"></p>
        </td>
        <td height="38">Your Role
          <p><textarea rows="3" name="ProjectRole" cols="23"></textarea></p>
        </td>
        <td height="38">More Detail
          <p><textarea rows="3" name="ProjectDetail" cols="22"></textarea></p>
        </td>
        <td height="38">
          <p align="center">Not Deletable</p>
        </td>
    </tr>
</table>
&nbsp;
<p align="right">&nbsp;


<script language=javascript>
    rowCount = 1
    function addRow(){
        rowCount ++
        newRow = document.getElementById("baseRow").cloneNode(true)
        newRow.childNodes[0].childNodes[1].name = "ProjectStart" + rowCount    //first input in first cell
        newRow.childNodes[0].childNodes[1].value = ""
        newRow.childNodes[1].childNodes[1].name = "ProjectFinish" + rowCount    //first input in second cell
        newRow.childNodes[1].childNodes[1].value = ""
        newRow.childNodes[2].childNodes[1].name = "OrganisationName" + rowCount    //first input in third cell
        newRow.childNodes[2].childNodes[1].value = ""
        newRow.childNodes[3].childNodes[1].name = "ProjectRole" + rowCount    //first input in fourth cell
        newRow.childNodes[3].childNodes[1].value = ""
        newRow.childNodes[4].childNodes[1].name = "ProjectDetail" + rowCount    //first input in fifth cell
        newRow.childNodes[4].childNodes[1].value = ""
        newRow.id = "row" + rowCount
        newButton = document.createElement("input")
        newButton.id = "button" + rowCount
        newButton.type = "button"
        newButton.value = "Delete"
        newButton.attachEvent("onclick", deleteRow)
        newRow.childNodes[5].childNodes[0].replaceNode(newButton) 
        
        document.getElementById("baseRow").parentNode.appendChild(newRow)
    }
    
    function deleteRow(){
        buttonID = event.srcElement.id        // ie - "button2"
        rowID = buttonID.substr(6)            // ie - "2"
        document.getElementById("row" + rowID).removeNode(true)
    }
</script>
<input type="submit" value="Submit &gt;&gt;"> 
<input type="button" value="Disagree &amp; Back" onClick="history.go(-1)">  </p>
<p align="center">&nbsp;&nbsp;&nbsp; <input type="reset" value=" Reset "></p>
<input type="hidden" name="cryptKey" value="<%= strSecurityKey %>">
</form>
			
		</table>
		<!-- #include file="footer.asp" -->		
</body>
<%
 'Close Objects
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing
%>

Thanks in advance

Richard Noon
 
Do you have good input?

Insert something like this at the top of your page:
Code:
Response.Write "JobStart = " & Request("JobStart").Count & "<BR>" & vbCrLf
Response.Write "JobFinish = " & Request("JobFinish").Count & "<BR>" & vbCrLf
Response.Write "EmployerName = " & Request("EmployerName").Count & "<BR>" & vbCrLf
Response.Write "JobRole = " & Request("JobRole").Count & "<BR>" & vbCrLf
Response.Write "JobDetail = " & Request("JobDetail").Count & "<BR>" & vbCrLf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top