I have an SQL database that contains three columns in my table. Date, hour, and code are the three fields. My form on my ASP page contains these three fields but multiple lines. For each line in the ASP table I want it to create a new record in the database. I have never done ASP this type of thing before and didn't know the best way to do it. I found some sample code on multiple inserting of records and don't quite understand how there downing it. There example is a 3 row table with Product, Description, and Price as the columns. Here is there sample ASP insert. For one is this good code?? ALso why do they seem to split things by Comma? Is that the way to do it? Does someone know of a better way or example?
if request("Selected2"
<> "" Then
productarray=split(request("Product"
,","![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
descrarray=split(request("Descr"
,","![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
pricearray=split(request("Price"
,","![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
for i=0 to ubound(productarray)
if len(trim(productarray(i))) > 0 then
rs.addnew
rs("Product"
=trim(productarray(i))
rs("Description"
=trim(descrarray(i))
rs("Price"
=trim(pricearray(i))
rs.update
end if
next
response.redirect "MultipleInsert.asp"
end if
%>
Second here is there Form Code.
<table width="400" border="0">
<tr>
<td>Sample2</td>
<td> </td>
<td>
<input type="submit" name="Submit" value="Insert">
</td>
</tr>
<tr>
<td>Product</td>
<td>Description</td>
<td>Price</td>
</tr>
<tr>
<td>
<input type="text" name="Product">
</td>
<td>
<input type="text" name="Descr">
</td>
<td>
<input type="text" name="Price">
</td>
</tr>
<tr>
<td>
<input type="text" name="Product">
</td>
<td>
<input type="text" name="Descr">
</td>
<td>
<input type="text" name="Price">
</td>
</tr>
<tr>
<td>
<input type="text" name="Product">
</td>
<td>
<input type="text" name="Descr">
</td>
<td>
<input type="text" name="Price">
</td>
</tr>
</table>
<input type="hidden" name="Selected2" value="1">
</form>
if request("Selected2"
productarray=split(request("Product"
descrarray=split(request("Descr"
pricearray=split(request("Price"
for i=0 to ubound(productarray)
if len(trim(productarray(i))) > 0 then
rs.addnew
rs("Product"
rs("Description"
rs("Price"
rs.update
end if
next
response.redirect "MultipleInsert.asp"
end if
%>
Second here is there Form Code.
<table width="400" border="0">
<tr>
<td>Sample2</td>
<td> </td>
<td>
<input type="submit" name="Submit" value="Insert">
</td>
</tr>
<tr>
<td>Product</td>
<td>Description</td>
<td>Price</td>
</tr>
<tr>
<td>
<input type="text" name="Product">
</td>
<td>
<input type="text" name="Descr">
</td>
<td>
<input type="text" name="Price">
</td>
</tr>
<tr>
<td>
<input type="text" name="Product">
</td>
<td>
<input type="text" name="Descr">
</td>
<td>
<input type="text" name="Price">
</td>
</tr>
<tr>
<td>
<input type="text" name="Product">
</td>
<td>
<input type="text" name="Descr">
</td>
<td>
<input type="text" name="Price">
</td>
</tr>
</table>
<input type="hidden" name="Selected2" value="1">
</form>