Connecting Tech Pros Worldwide Forums | Help | Site Map

Insert multiple rows: from table web form into SQL table

Newbie
 
Join Date: Sep 2008
Posts: 2
#1: Sep 15 '08
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:
Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2. <!--#include file="../../../Connections/BILLING.asp" -->
  3. <%
  4. FEQUIPID = Request.form("EQUIPID") ' Convert the info from the form to a string
  5.  
  6. MakeEQUIPID = Replace(FEQUIPID, ", ", "' OR EQUIPID= '") ' Replace comma-space to single quote - OR EQUIPID= - single quote
  7.  
  8. %>
  9. <%
  10. Dim Recordset1
  11. Dim Recordset1_numRows
  12.  
  13. Set Recordset1 = Server.CreateObject("ADODB.Recordset")
  14. Recordset1.ActiveConnection = MM_BILLING_STRING
  15. Recordset1.Source = "SELECT *, EQUIPID  FROM dbo.BP_Progressor_Non_P2P_Equip_Id  WHERE (EQUIPID = '" & MakeEQUIPID & "')"
  16. Recordset1.CursorType = 0
  17. Recordset1.CursorLocation = 2
  18. Recordset1.LockType = 1
  19. Recordset1.Open()
  20.  
  21. Recordset1_numRows = 0
  22. %>
  23. <%
  24. Dim Repeat1__numRows
  25. Dim Repeat1__index
  26.  
  27. Repeat1__numRows = -1
  28. Repeat1__index = 0
  29. Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
  30. %>
  31. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  32. <html xmlns="http://www.w3.org/1999/xhtml">
  33. <head>
  34. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  35. <title>Untitled Document</title>
  36. </head>
  37.  
  38. <body>
  39. <div align="center">
  40.   <form id="form1" name="form1">
  41.     <p>&nbsp;</p>
  42.     <table width="751">
  43.       <tr>
  44.         <td width="175"><div align="center"></div></td>
  45.         <td width="73"><div align="center"></div></td>
  46.         <td width="144">&nbsp;</td>
  47.         <td width="167"><div align="center"></div></td>
  48.         <td width="168"><div align="center"></div></td>
  49.       </tr>
  50.       <% 
  51. While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
  52. %>
  53.         <tr>
  54.           <td><div align="center"><%=(Recordset1.Fields.Item("EQUIPID").Value)%></div></td>
  55.           <td><div align="center"><%=(Recordset1.Fields.Item("EQUIPNAME").Value)%></div></td>
  56.           <td><div align="center">
  57.             <input name="Job_No" type="text" id="Job_No" value="<%= Request.QueryString("Job_No") %>" />
  58.           </div></td>
  59.           <td><div align="center">
  60.             <input name="VAT" type="text" id="VAT" />
  61.           </div></td>
  62.           <td><div align="center">
  63.             <input name="Rate" type="text" id="Rate" />
  64.           </div></td>
  65.         </tr>
  66.         <% 
  67.   Repeat1__index=Repeat1__index+1
  68.   Repeat1__numRows=Repeat1__numRows-1
  69.   Recordset1.MoveNext()
  70. Wend
  71. %>
  72.  
  73.         </table>
  74.     <p>
  75.       <input type="submit" name="Submit" value="Submit" />
  76.     </p>
  77.     <p>&nbsp;</p>
  78.   </form>
  79. </div>
  80. </body>
  81. </html>
  82. <%
  83. Recordset1.Close()
  84. Set Recordset1 = Nothing
  85. %>

DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 930
#2: Sep 15 '08

re: Insert multiple rows: from table web form into SQL table


Hi edtrvl,

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

Dr B
Newbie
 
Join Date: Sep 2008
Posts: 2
#3: Oct 20 '08

re: Insert multiple rows: from table web form into SQL table


The rows aren't inserting, nothing seems to be happening.
iam_clint's Avatar
Forum Leader
 
Join Date: Jul 2006
Location: Oklahoma
Posts: 1,076
#4: Oct 20 '08

re: Insert multiple rows: from table web form into SQL table


I don't see you using addNew or Update anywhere in the code snippet you pasted...
example
Expand|Select|Wrap|Line Numbers
  1. rs.open strSQL, cn, 1, 1
  2. rs.addnew
  3. rs("cat_name") = "charlie"
  4. rs("cat_friend") = "Bob"
  5. rs.update
  6. rs.close
  7.  
Newbie
 
Join Date: Feb 2008
Posts: 4
#5: Oct 23 '08

re: Insert multiple rows: from table web form into SQL table


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
Reply


Similar ASP / Active Server Pages bytes