Link to home
Start Free TrialLog in
Avatar of eteran
eteranFlag for United States of America

asked on

I have three diffrent records going to the same table at the same time How do I do it.

Below I posted my HTML code so you can view the three contacts. These contacts are going to the same table in the database. I have no clue on how to structure my sql to insert the three contacts one by one.

Below I posted my normal conection string I use. I need help in modifing it with a loop to take in all three records.

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Add Contact</title>
</head>

<body>

<form method="POST" action="staffinputcontact.asp?id=<%=Request.Querystring("ID")%>&agentid=<%=Request.Querystring("Agentid")%>&type=<%=Request.Querystring("type")%>">
  <%for i=1 to 3%>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFCC" width="50%" height="20" id="table4">
    <tr>
      <td width="100%" height="20" colspan="4" bgcolor="#89AE79">
      <p align="center"><b><font face="Arial" color="#FFFFCC">Enter Buyer or
            Renter Information</font></b></td>
    </tr>
    <tr>
      <td width="17%" height="20" bgcolor="#D3E0CF" align="right"><b>
      <font face="Arial" size="2">Company:</font></b></td>
      <td width="83%" height="20" colspan="3" bgcolor="#D3E0CF">
      <font face="Arial"><b><input type="text" name="Company<%=i%>" size="31"></b></font></td>
    </tr>
    <tr>
      <td width="17%" height="20" bgcolor="#D3E0CF" align="right"><b>
      <font face="Arial" size="2">First name:</font></b></td>
      <td width="83%" height="20" colspan="3" bgcolor="#D3E0CF">
      <font face="Arial"><b><input type="text" name="Name<%=i%>" size="28"></b></font></td>
    </tr>
    <tr>
      <td width="17%" height="20" bgcolor="#D3E0CF" align="right"><b>
      <font face="Arial" size="2">Last name:</font></b></td>
      <td width="59%" height="20" bgcolor="#D3E0CF"><font face="Arial"><b>
      <input type="text" name="Last_name<%=i%>" size="28"></b></font></td>
      <td width="7%" height="20" bgcolor="#D3E0CF">&nbsp;</td>
      <td width="23%" height="20" bgcolor="#D3E0CF">&nbsp;</td>
    </tr>
    <tr>
      <td width="17%" height="20" bgcolor="#D3E0CF" align="right"><b>
      <font face="Arial" size="2">Address:</font></b></td>
      <td width="59%" height="20" bgcolor="#D3E0CF"><font face="Arial"><b>
      <input type="text" name="Address<%=i%>" size="31"></b></font></td>
      <td width="7%" height="20" bgcolor="#D3E0CF"><b>
      <font face="Arial" size="2">Apt:</font></b></td>
      <td width="23%" height="20" bgcolor="#D3E0CF"><font face="Arial"><b>
      <input type="text" name="Apt<%=i%>" size="9"></b></font></td>
    </tr>
    <tr>
      <td width="17%" height="20" bgcolor="#D3E0CF" align="right"><b>
      <font face="Arial" size="2">City:</font></b></td>
      <td width="83%" height="20" colspan="3" bgcolor="#D3E0CF">
      <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFCC" width="100%" id="table5">
        <tr>
          <td width="25%"><font face="Arial"><b>
          <input type="text" name="City<%=i%>" size="11"></b></font></td>
          <td width="15%">
          <p align="right"><b><font face="Arial" size="2">State:</font></b></td>
          <td width="19%"><font face="Arial"><b>
          <input type="text" name="State<%=i%>" size="6"></b></font></td>
          <td width="9%">
          <p align="right"><b><font face="Arial" size="2">Zip:</font></b></td>
          <td width="32%"><font face="Arial"><b>
          <input type="text" name="Zip<%=i%>" size="14"></b></font></td>
        </tr>
      </table>
      </td>
    </tr>
    <tr>
      <td width="17%" height="20" bgcolor="#D3E0CF">&nbsp;</td>
      <td width="83%" height="20" colspan="3" bgcolor="#D3E0CF">&nbsp;</td>
    </tr>
    <tr>
      <td width="100%" height="20" colspan="4" bgcolor="#D3E0CF">
      <p align="center"><b><font face="Arial" size="2">Contact Information</font></b></td>
    </tr>
    <tr>
      <td width="100%" height="20" colspan="4" bgcolor="#D3E0CF">
      <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="table6">
        <tr>
            <td width="25%" height="26" align="right" bordercolor="#FFFFCC"><b>
              <font face="Arial" size="2">Home:</font></b></td>
          <td width="25%" bordercolor="#FFFFCC" align="right">
          <font face="Arial"><b><input type="text" name="Home<%=i%>" size="14"></b></font></td>
          <td width="25%" bordercolor="#FFFFCC" align="right"><b>
          <font face="Arial" size="2">Cell:</font></b></td>
          <td width="25%" bordercolor="#FFFFCC"><font face="Arial"><b>
          <input type="text" name="Cell<%=i%>" size="14"></b></font></td>
        </tr>
        <tr>
          <td width="25%" bordercolor="#FFFFCC" align="right"><b>
          <font face="Arial" size="2">Business:</font></b></td>
          <td width="25%" bordercolor="#FFFFCC" align="right">
          <font face="Arial"><b><input type="text" name="Business<%=i%>" size="14"></b></font></td>
          <td width="25%" bordercolor="#FFFFCC" align="right"><b>
          <font face="Arial" size="2">Fax or Other:</font></b></td>
          <td width="25%" bordercolor="#FFFFCC"><font face="Arial"><b>
          <input type="text" name="Other<%=i%>" size="14"></b></font></td>
        </tr>
        <tr>
          <td width="100%" bordercolor="#FFFFCC" colspan="4">
          <p align="center"><b><font face="Arial" size="2">Email</font></b></td>
        </tr>
        <tr>
          <td width="100%" bordercolor="#FFFFCC" colspan="4" align="center"><font face="Arial">
          <b><input type="text" name="Email<%=i%>" size="31"></b></font></td>
        </tr>
        <tr>
          <td width="25%" bgcolor="#89AE79" bordercolor="#FFFFCC">&nbsp;</td>
          <td width="50%" colspan="2" bgcolor="#89AE79" bordercolor="#FFFFCC">
          <p align="center"><font face="Arial"><b>
          </b></font></td>
          <td width="25%" bgcolor="#89AE79" bordercolor="#FFFFCC">&nbsp;</td>
        </tr>
      </table>
      </td>
    </tr>
  </table>
  <%next%>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFCC" width="50%" height="20" id="table4">
    <tr>
      <td width="100%" height="20" colspan="9" bgcolor="#89AE79"> <p align="center">
          <input type=hidden name="intRecords" value="<%=i%>">
            <b><font face="Arial" color="#FFFFCC">&nbsp; Enter Agents
                  Information</font></b></td>
    </tr>
   
    <tr>
      <td width="16%" height="20" bgcolor="#D3E0CF" align="right">
            <p align="right"><b>
      <font face="Arial" size="2">Company:</font></b></td>
      <td width="83%" height="20" colspan="8" bgcolor="#D3E0CF">
      <font face="Arial"><b><input type="text" name="Company<%=i%>0" size="31"></b></font></td>
    </tr>
   
    <tr>
      <td width="16%" height="20" bgcolor="#D3E0CF" align="right"> <b>
      <font face="Arial" size="2">First name:</font></b></td>
      <td width="83%" height="20" colspan="8" bgcolor="#D3E0CF">
      <font face="Arial"><b><input type="text" name="Name<%=i%>0" size="28"></b></font></td>
    </tr>
   
    <tr>
      <td width="16%" height="20" bgcolor="#D3E0CF" align="right"> <b>
      <font face="Arial" size="2">Last name:</font></b></td>
      <td width="83%" height="20" colspan="8" bgcolor="#D3E0CF"> <font face="Arial"><b>
      <input type="text" name="Last_name<%=i%>0" size="28"></b></font></td>
    </tr>
   
    <tr>
      <td width="16%" height="20" bgcolor="#D3E0CF" align="right"> <b>
      <font face="Arial" size="2">Address:</font></b></td>
      <td width="42%" height="20" colspan="4" bgcolor="#D3E0CF"> <font face="Arial"><b>
      <input type="text" name="Address<%=i%>0" size="31"></b></font></td>
      <td width="21%" height="20" colspan="2" bgcolor="#D3E0CF">
            <p align="right"><b><font face="Arial" size="2">APT:</font></b></td>
      <td width="20%" height="20" colspan="2" bgcolor="#D3E0CF"> <font face="Arial"><b>
      <input type="text" name="Apt<%=i%>0" size="9"></b></font></td>
    </tr>
   
    <tr>
      <td width="16%" height="20" bgcolor="#D3E0CF" align="right"> <b>
      <font face="Arial" size="2">City:</font></b></td>
      <td width="18%" height="20" colspan="2" bgcolor="#D3E0CF"> <font face="Arial"><b>
          <input type="text" name="City<%=i%>0" size="11"></b></font></td>
      <td width="7%" height="20" bgcolor="#D3E0CF"> <b><font face="Arial" size="2">State:</font></b></td>
      <td width="27%" height="20" colspan="2" bgcolor="#D3E0CF"> <font face="Arial"><b>
          <input type="text" name="State<%=i%>0" size="6"></b></font></td>
      <td width="10%" height="20" colspan="2" bgcolor="#D3E0CF"> <b><font face="Arial" size="2">Zip:</font></b></td>
      <td width="20%" height="20" bgcolor="#D3E0CF"> <font face="Arial"><b>
          <input type="text" name="Zip<%=i%>0" size="14"></b></font></td>
    </tr>
   
    <tr>
      <td width="16%" height="20" bgcolor="#D3E0CF" align="right"> &nbsp;</td>
      <td width="83%" height="20" colspan="8" bgcolor="#D3E0CF"> &nbsp;</td>
    </tr>
   
    <tr>
      <td width="99%" height="20" colspan="9" bgcolor="#D3E0CF" align="right">
            <p align="center"><b><font face="Arial" size="2">Contact Information</font></b></td>
    </tr>
   
    <tr>
      <td width="128" height="20" colspan="2" bgcolor="#D3E0CF" align="right"> <b>
              <font face="Arial" size="2">Home:</font></b></td>
      <td width="25%" height="20" colspan="2" bgcolor="#D3E0CF" align="right">
          <font face="Arial"><b><input type="text" name="Home<%=i%>0" size="14"></b></font></td>
      <td width="25%" height="20" colspan="3" bgcolor="#D3E0CF" align="right"> <b>
          <font face="Arial" size="2">Cell:</font></b></td>
      <td width="24%" height="20" colspan="2" bgcolor="#D3E0CF" align="right"> <font face="Arial"><b>
          <input type="text" name="Cell<%=i%>0" size="18"></b></font></td>
    </tr>
   
    <tr>
      <td width="128" height="20" colspan="2" bgcolor="#D3E0CF" align="right"> <b>
          <font face="Arial" size="2">Business:</font></b></td>
      <td width="25%" height="20" colspan="2" bgcolor="#D3E0CF" align="right">
          <font face="Arial"><b>
            <input type="text" name="Business<%=i%>0" size="14"></b></font></td>
      <td width="25%" height="20" colspan="3" bgcolor="#D3E0CF" align="right"> <b>
          <font face="Arial" size="2">Fax or Other:</font></b></td>
      <td width="24%" height="20" colspan="2" bgcolor="#D3E0CF" align="right"> <font face="Arial"><b>
          <input type="text" name="Other<%=i%>0" size="18"></b></font></td>
    </tr>
   
    <tr>
      <td width="99%" height="20" colspan="9" bgcolor="#D3E0CF" align="right">
            <p align="center"><b><font face="Arial" size="2">Email</font></b></td>
    </tr>
   
    <tr>
      <td height="20" colspan="9" bgcolor="#D3E0CF" align="right">
            <p align="center"><font face="Arial">
          <b><input type="text" name="Email<%=i%>0" size="31"></b></font></td>
    </tr>
   
    <tr>
      <td width="100%" height="20" colspan="9" bgcolor="#89AE79">
            <p align="center"><b><font face="Arial" color="#FFFFCC">&nbsp;Enter
            Seller or Landlord Information</font></b></td>
    </tr>
   
        <tr>
      <td width="16%" height="20" bgcolor="#D3E0CF" align="right">
            <p align="right"><b>
      <font face="Arial" size="2">Company:</font></b></td>
      <td width="83%" height="20" colspan="8" bgcolor="#D3E0CF">
      <font face="Arial"><b><input type="text" name="Company<%=i%>1" size="31"></b></font></td>
    </tr>
      <tr>
      <td width="16%" height="20" bgcolor="#D3E0CF" align="right"> <b>
      <font face="Arial" size="2">First name:</font></b></td>
      <td width="83%" height="20" colspan="8" bgcolor="#D3E0CF">
      <font face="Arial"><b><input type="text" name="Name<%=i%>1" size="28"></b></font></td>
    </tr>
      <tr>
      <td width="16%" height="20" bgcolor="#D3E0CF" align="right"> <b>
      <font face="Arial" size="2">Last name:</font></b></td>
      <td width="83%" height="20" colspan="8" bgcolor="#D3E0CF"> <font face="Arial"><b>
      <input type="text" name="Last_name<%=i%>1" size="28"></b></font></td>
    </tr>
    <tr>
      <td width="100%" height="20" colspan="9" bgcolor="#89AE79">
            <p align="center">
            <input type="submit" value="Submit" name="B5"><input type="reset" value="Reset" name="B6"></td>
    </tr>
   
    <tr>
      <td width="100%" height="20" colspan="9" bgcolor="#89AE79"> &nbsp;</td>
    </tr>
   
  </table>
</form>
</body>

</html>
_____+++++++======___________
Conection String posted.
<%
'Dimension variables
Dim adoCon                   'Holds the Database Connection Object
Dim rsAddComments      'Holds the recordset for the new record to be added to the database
Dim strSQL                  'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
ID=Request.Querystring("ID")
'Set an active connection to the Connection object using a DSN-less connection

set Conn = Server.CreateObject("ADODB.Connection")
adoCon.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=F:\hshome\siloc\Data\siloc.mdb"

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL  = "select * from T_Contact;"

rsAddComments.CursorType = 2
rsAddComments.LockType = 3

rsAddComments.Open strSQL, adoCon

rsAddComments.AddNew
rsAddComments("Type1") = Request.Querystring("type")
rsAddComments("Transaction_ID") = Request.Querystring("id")
rsAddComments("Agent_ID") = Request.Querystring("Agentid")

For Each Field in rsAddComments.Fields
  If i < 46 ANd Not IsEmpty(Request.Form(Field.Name)) Then
    Field.Value = MyValue(Field)
  End If
Next

rsAddComments.Update
contactid = rsAddComments("Transaction_ID")
typecon = rsAddComments("Type1")
id = rsAddComments("Contact_ID")
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing



Response.Redirect "Staffviewcontact.asp?ID=" & contactid & "&type=" & typecon


Function MyValue(o)
  Select Case o.Type
  Case 11
    If Request.Form(o.Name) = "ON" Then
      MyValue = -1
    Else
      MyValue = 0
    End If
  Case 3
    If IsNumeric(Request.Form(o.Name)) Then  
 MyValue = CLng(Request.Form(o.Name))
    Else
      MyValue = Null
    ENd If
  Case 7, 133, 134, 135
    If IsDate(Request.Form(o.Name)) Then
      MyValue = CDate(Request.Form(o.Name))
    Else
      MyValue = Null
    End If
  Case Else
    MyValue = Request.Form(o.Name)
  End Select
End Function
%>
Avatar of poopall
poopall

Its simple when the form is posted as the name tag is the same for each record, it will get passed as an array. If you want them updated one at a time then put a form tag and a submit button around each one. So in the page staffinputcontact.asp, you will have to use something like for i = 0 to uBound( etc etc.


Dim company(2), name(2), state(2)

<%

'This put the values in an array - arrays start from 0 thats why i have added 1 to the i counter in the code below

for i = 0 to 2
   Company(i) = request.form("Company" & i+1 )
   Name(i) = request.form("Name" & i+1 )
   State(i) = request.form("state" & i+1 )
next

'This is the part that inserts the data in the db

for i = 0 to 2
   sql = "INSERT INTO table (Company, state, name) VALUES ('"&Company(i)"', '"&state(i)&"', '"&Name(i)&"')"
   adocon.execute(sql)
next


%>

Is this wht u are after
obiouslt i have just used 3 random fields, but depending on how many you have remember to add an array for each of the fields:

Dim company(2), name(2), state(2), [One omre for each field]

Remember to add what you have declared in the loops that fill the arrays:

for i = 0 to 2
   Company(i) = request.form("Company" & i+1 )
   Name(i) = request.form("Name" & i+1 )
   State(i) = request.form("state" & i+1 )
   [What ever you have Dimd goes here]
next

And remember to add to the db insert statement

sql = "INSERT INTO table (Company, state, name, [ADD THE FIELDS TO BE INSERTED INTO]) VALUES ('"&Company(i)"', '"&state(i)&"', '"&Name(i)&"', [ADD ONE FOR EACH ARRAY])"

Please note, when using variables in an sql statement, if you KNOW that the field thats being inserted to is a Number field present you variable like this:

" & variable  & "

If you knows its text do this:

' " & variable & " '

if you know its date or time do this:

# " & variable & " # >>>This may vary depending on your db, it oculd be the same as text

Hope this has helped, good luck

Apresto
Avatar of eteran

ASKER

so do I have to change my form at all or I can leave the names. How Do I create the form so the loop statement can disifer the diffrence.
Avatar of Anthony Perkins
Please maintain these abandoned questions:
1 09/26/2004 500 Check this code  Open Active Server Pages (ASP)
2 10/21/2004 500 Form Question  Open Active Server Pages (ASP)

Thanks.
Avatar of eteran

ASKER

they are not abaned just have not been answered
Avatar of eteran

ASKER

correctly
Questions are considered technically abandoned after three weeks.  Also,see here:
What are my choices?
https://www.experts-exchange.com/Web/Web_Languages/ASP/help.jsp#hi67
These are the fields i have managed to see:

Company
Name
Last_Name
Address
Apt
City
State
Zip
Home
Cell
Business
Other
Email
IntRecords

To call one of these roecrds, just add an array to the list of Dim'ed arrays and name it something that related to the called value (ie for company call it company ;o)) Then in the SQL to update the db add a new field and a value(variable) to go into that field using the syntax i have given you for the i, then the adocon.executer and the for loop will do the rest - try it out, any probs, im here to help if i can
Avatar of eteran

ASKER

I can't get it to work. I am confused. I have all my text fields in whcih the data wil be entered on my form. Now I need to create an array with the fields below. How do I go about doing this. I have never worked with arrays before,.

Company
Name
Last_Name
Address
Apt
City
State
Zip
Home
Cell
Business
Other
Email
Thank you for following up on the oldest question, but you appear to have overlooked the other question:
https://www.experts-exchange.com/questions/21178101/Form-Question.html
Avatar of eteran

ASKER

Well that question has not been answered to my needs. I am a paying member to your site. And I don't mind paying points so long as the answer is answered. If not I usallualy try figuring it out by my self and then I post the answer
First of all, let's set the record straight, this is not my site, it is OUR site, I am just one more member like yourself, who has volunteered a considerable amount of my time cleaning-up abandoned questions such as your own.

The guidelines on EE are very simple and very clear, I urge you to re-read them.  If you feel that your question was not answered than say so, how do you expect people here to know whether it meets your requirements or not, if you do not bother to submit one single follow-up comment?  If after doing that, you still do not get an asnwer to your question, than again from the EE Guidelines:
I answered my question myself. What do I do?
https://www.experts-exchange.com/Web/Web_Languages/ASP/help.jsp#hi70
Or
Nobody answered my question. What do I do?
https://www.experts-exchange.com/Web/Web_Languages/ASP/help.jsp#hi71

Your questions are your responsibility, you can choose to ignore them if you wish:
What happens if I don't close my question?
https://www.experts-exchange.com/Web/Web_Languages/ASP/help.jsp#hi78

Thank you for taking care of your abandoned questions.

If you feel my comments are inappropriate, feel free to post a message in Community Support to this effect.  Make sure to include a reference to this thread.
You create a sepoerate array for each of the form fields, name the array the same as the form field only with a number in brackets next to it (2) - arrays start from 0 so i fyou want to store 3 values in an array the array num is (2), if you want to store 2 values its (1).

to get your values in the arrays is this bit of code:

for i = 0 to 2
   Company(i) = request.form("Company" & i+1 )
   Name(i) = request.form("Name" & i+1 )
   State(i) = request.form("state" & i+1 )
  'Add the rest of your arrays, i.e. address(2), zip(2) etc
next

Ill break it down,

Company(i) means "put the following in the aray slot that is equal to i"

= request.form("company" & i+1)

In your form you have for i = 1 to 3

and here were are starting the array from 0 so we need to add one to the value rquested from the form in order to have it picked up correctly so:

requerst.form("company") 0 + 1" because the first instance of i is 0.

Do you know what mean, for now just create an array for each of your field: whatever(2)

the add the array to the part that fills them with values (The bit of code above), if you dont understand post back and ill do it for you and explain what i have done in greater details once its working as arrays are an important part of programming

Let me know how you get on and dont worry if you dont get it, i didnt first time either
i have been looking at your code, why do you have some input fields with a value of i AFTER your Next, these i's are not in a loop, how will they work?

Example:

  <%next%> '>>>THIS is where you FOR LOOP ENDS
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FFFFCC" width="50%" height="20" id="table4">
    <tr>
      <td width="100%" height="20" colspan="9" bgcolor="#89AE79"> <p align="center">
          <input type=hidden name="intRecords" value="<%=i%>"> >>>LINE 125

What is the value of the i represented in this input field?

i think after the NEXT the values of i is going to be 4, is this wht you want?
I tihnk i sort of understand this code, i just dont understand how you have lebelled them, but this is how i would do it for the fields within the loop as these fields will have a valuesof their fieldname and a nuber from 1 to 3.

Dim company(2), name(2), last_name(2), address(2), apt(2), City(2), state(2), zip(2), Home(2), cell(2), business(2), other(2), email(2)

for i = 0 to 2
   Company(i) = request.form("Company" & i+1 )
   Name(i) = request.form("Name" & i+1 )
   Last_name(i) = request.form("last_name" & i + 1)
   Address(i) = request.form("address" & i + 1)
   Apt(i) = request.form("apt"  & i + 1)
   City(i) = request.form("city"  & i + 1)
   State(i) = request.form("state" & i+1 )
   Zip(i) = request.form("zip"  & i + 1)
   Home(i) = request.form("Home"  & i + 1)
   Cell(i) = request.form("Cell"  & i + 1)
   Business(i) = request.form("Business"  & i + 1)
   Other(i) = request.form("Other"  & i + 1)
   Email(i) = request.form("Email"  & i + 1)
next

I would suggest doing this:

for i = 1 to 3
response.write nameofarray1(i) & "<BR>" & nameofarray2 & "<br>" & ...etc chaneg "nameofarray1 and 2" to the name of your arrays
response.write "<hr>"
next

This will write all of the values in the array to the screen so you can see what it does, this might clear things up for you and allow you to understand the concept of an array

After which you can go to update your db with the code below

for i = 0 to 2
   sql = "INSERT INTO table (Company, state, name) VALUES ('"&Company(i)"', '"&state(i)&"', '"&Name(i)&"')"
   adocon.execute(sql)
next

But you will need to change this to include the fields and values you want to update, wbut we will get to that. Have i understood what you need to do, if so am i on the right track and im not too sure i know whats goin on =)
Also on a different note, you cant say your other questions were not answered as you did not supply any feedback tpo the experts trying to help you.  Unless you guide them along with progress they cant answer your question.  I attempted to help out with the "FORM question" but you havent posted back and my guess is as good as the other experts who commented.
Avatar of eteran

ASKER

If you look at the first code  i POSTED  it will show you my fields on the form i created. What I need to get an idea is how I can use my current connection string to work with the array that I will be useing to put  the info intoi the data below I post my connection string<%
'Dimension variables
Dim adoCon                'Holds the Database Connection Object
Dim rsAddComments     'Holds the recordset for the new record to be added to the database
Dim strSQL               'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
ID=Request.Querystring("ID")
'Set an active connection to the Connection object using a DSN-less connection

set Conn = Server.CreateObject("ADODB.Connection")
adoCon.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=F:\hshome\siloc\Data\siloc.mdb"

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL  = "select * from T_Contact;"

rsAddComments.CursorType = 2
rsAddComments.LockType = 3

rsAddComments.Open strSQL, adoCon

rsAddComments.AddNew
rsAddComments("Type1") = Request.Querystring("type")
rsAddComments("Transaction_ID") = Request.Querystring("id")
rsAddComments("Agent_ID") = Request.Querystring("Agentid")

For Each Field in rsAddComments.Fields
  If i < 46 ANd Not IsEmpty(Request.Form(Field.Name)) Then
    Field.Value = MyValue(Field)
  End If
Next

rsAddComments.Update
contactid = rsAddComments("Transaction_ID")
typecon = rsAddComments("Type1")
id = rsAddComments("Contact_ID")
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing



Response.Redirect "Staffviewcontact.asp?ID=" & contactid & "&type=" & typecon


Function MyValue(o)
  Select Case o.Type
  Case 11
    If Request.Form(o.Name) = "ON" Then
      MyValue = -1
    Else
      MyValue = 0
    End If
  Case 3
    If IsNumeric(Request.Form(o.Name)) Then  
 MyValue = CLng(Request.Form(o.Name))
    Else
      MyValue = Null
    ENd If
  Case 7, 133, 134, 135
    If IsDate(Request.Form(o.Name)) Then
      MyValue = CDate(Request.Form(o.Name))
    Else
      MyValue = Null
    End If
  Case Else
    MyValue = Request.Form(o.Name)
  End Select
End Function
%>
From what i understand you have a number of form fields in the first posting that have same name, different number on the end, correct?

what you would do is this to update if you want to use your current method:

For x = 1 to 4 '(assuming your fields range 1 to 4)
  rsAddcomments.addnew
  rsAddcomments("type1")= request.form("type" & x)
  rsAddcomments("Transaction_ID") = request.form("id" & x)
  rsAddcomments("Agent_ID") = request.form("AgentId" & x)
  rsAddcomments.update
next

The code aboce loops through makeing the value of x = 1 the first time round and 2 the second, 3 the third and 4 the forth so in reality the code looks like this:


  rsAddcomments.addnew
  rsAddcomments("type1")= request.form("type1")
  rsAddcomments("Transaction_ID") = request.form("id1")
  rsAddcomments("Agent_ID") = request.form("AgentId1")
  rsAddcomments.update

  rsAddcomments.addnew
  rsAddcomments("type1")= request.form("type2")
  rsAddcomments("Transaction_ID") = request.form("id2")
  rsAddcomments("Agent_ID") = request.form("AgentId2")
  rsAddcomments.update

Sorry if its not what you need, its been a while and i cant remember exactly what i had in mind!
Avatar of eteran

ASKER

well. THe real thing I am trying to do is add three diffrent records byuseing a loop to the same table on the same submit. I am really confuesed. For example, Lets say that the user is dealing with the buyer to a trasaction. When so, the agent will be promt to input the sellers name becuase he is not dealing with the seller but the buyer. THey would input all the buyerinformation; like;  Buyer address phone numbers and so on. the agent that represents the seller will need their informaiton posted on the site so now the inputter will have insert three diffent contacts seller, buyer and agent. These fileds are going to be inputted to the same table useing the same ID number from the transaction id that was given by the system to input the information. Seller, buyer and agent would be entered by the same tran id  from another table that hold the transaction informqtion .  
Eteran,

You were reminded on December 4 by an EE volunteer to follow up on this open question:
https://www.experts-exchange.com/questions/21178101/Form-Question.html

Please do so.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of apresto
apresto
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial