Insert multiple rows: from table web form into SQL table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • edtrvl
    New Member
    • Sep 2008
    • 2

    Insert multiple rows: from table web form into SQL table

    Hi there,
    I'm trying to insert multiple rows from a table format web form into multiple rows in a SQL table, (1 row for 1 row).
    Any help would be greatly appreciated, thanks in advance

    Here's the code of my page:
    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!--#include file="../../../Connections/BILLING.asp" -->
    <%
    FEQUIPID = Request.form("EQUIPID") ' Convert the info from the form to a string
    
    MakeEQUIPID = Replace(FEQUIPID, ", ", "' OR EQUIPID= '") ' Replace comma-space to single quote - OR EQUIPID= - single quote
    
    %>
    <%
    Dim Recordset1
    Dim Recordset1_numRows
    
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection = MM_BILLING_STRING
    Recordset1.Source = "SELECT *, EQUIPID  FROM dbo.BP_Progressor_Non_P2P_Equip_Id  WHERE (EQUIPID = '" & MakeEQUIPID & "')"
    Recordset1.CursorType = 0
    Recordset1.CursorLocation = 2
    Recordset1.LockType = 1
    Recordset1.Open()
    
    Recordset1_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index
    
    Repeat1__numRows = -1
    Repeat1__index = 0
    Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <div align="center">
      <form id="form1" name="form1">
        <p>&nbsp;</p>
        <table width="751">
          <tr>
            <td width="175"><div align="center"></div></td>
            <td width="73"><div align="center"></div></td>
            <td width="144">&nbsp;</td>
            <td width="167"><div align="center"></div></td>
            <td width="168"><div align="center"></div></td>
          </tr>
          <% 
    While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
    %>
            <tr>
              <td><div align="center"><%=(Recordset1.Fields.Item("EQUIPID").Value)%></div></td>
              <td><div align="center"><%=(Recordset1.Fields.Item("EQUIPNAME").Value)%></div></td>
              <td><div align="center">
                <input name="Job_No" type="text" id="Job_No" value="<%= Request.QueryString("Job_No") %>" />
              </div></td>
              <td><div align="center">
                <input name="VAT" type="text" id="VAT" />
              </div></td>
              <td><div align="center">
                <input name="Rate" type="text" id="Rate" />
              </div></td>
            </tr>
            <% 
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      Recordset1.MoveNext()
    Wend
    %>
    
            </table>
        <p>
          <input type="submit" name="Submit" value="Submit" />
        </p>
        <p>&nbsp;</p>
      </form>
    </div>
    </body>
    </html>
    <%
    Recordset1.Close()
    Set Recordset1 = Nothing
    %>
    Last edited by DrBunchman; Sep 15 '08, 11:07 AM. Reason: Added [Code] Tags - Please use the '#' button
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi edtrvl,

    What's the problem? Are you getting an error?

    Dr B

    Comment

    • edtrvl
      New Member
      • Sep 2008
      • 2

      #3
      The rows aren't inserting, nothing seems to be happening.

      Comment

      • iam_clint
        Recognized Expert Top Contributor
        • Jul 2006
        • 1207

        #4
        I don't see you using addNew or Update anywhere in the code snippet you pasted...
        example
        Code:
        rs.open strSQL, cn, 1, 1
        rs.addnew
        rs("cat_name") = "charlie"
        rs("cat_friend") = "Bob"
        rs.update
        rs.close

        Comment

        • narayananbabun
          New Member
          • Feb 2008
          • 4

          #5
          actually what is the problem u r having y r u having this much code for creating a recordset just one line is enough, and how do u wanted to insert whether u need to display the records from the db table in html table or u need to inert some field into u r db table from the field u have in ur page.mention that clearly

          Comment

          Working...