469,323 Members | 1,365 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Insert multiple rows: from table web form into SQL table

2
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. %>
Sep 15 '08 #1
4 5417
DrBunchman
979 Expert 512MB
Hi edtrvl,

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

Dr B
Sep 15 '08 #2
edtrvl
2
The rows aren't inserting, nothing seems to be happening.
Oct 20 '08 #3
iam_clint
1,208 Expert 1GB
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.  
Oct 20 '08 #4
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
Oct 23 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Martin | last post: by
12 posts views Thread by shank | last post: by
2 posts views Thread by wombat53 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.