Inserting Records Using A Loop
I want to insert records into a database using a loop. I've got a number of input fields named 1-50. I want to request each textfield and insert the data into a database table.
Whats the best way of doing this? I've tried a While... Wend loop but the loop seems to carry on.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Pulling Records From End Of A Database Or Inserting New Records To The Beginning
I'm trying to pull the last 5 records from my database. <% j=5 rs.MoveLast While ((j>0) AND (NOT rs_article.BOF))%> ''Execute HTML and data insertion here <%rs_article.MovePrevious j=j-1 Wend%> Everytime I attempt to run this code, I recieve an HTTP 500- Internal Server Error. It tells me no more than that. I know that my connection settings are OK because when I move forward through the database (first five records), the code executes without error. And yes, my Cursor type is Dynamic. Alternatively, I would also like to know how to add new recordset to the beginning of a database rather than the end.
Inserting 200 Values In Loop
I am reading about 200 records from dbf file in ASP code and inserting into a table. I fetch the records in a recordset and in the recordset loop I have to insert it into the SQL table. How should I insert the values? 1) Should I use query in ASP page 2) Or call stored procedure (passing each record parameter) for inserting, 200 times in the loop
Loop Twice Through Records
I have what may be a simple question, how do I loop through a set of records twice? Here's a snapshot of what I have. x = 0 do while rs.EOF = False dim i i = x %> <input type=text name="FirstName<%=i%> " value="<%=rs("Child_First")%>"> 'I'd like to be able to have these input fields posted twice for each record. <% x = x +1 rs.movenext loop >
Loop Through List And Add Records
I have a list in a form where allows multiple selections <select name="writerID" size="4" multiple > <option value="no" selected> ---- writer ---- </option> <% do until RS.eof %> <option> <%=RS(0)%> </option> <% RS.movenext loop %> </select> How do I make the loop in the add section where I have to retreive the records and add the selections?: For ?????? RS.AddNew RS("writerID") = request.form("writerID") RS.Update next
Loop + Adding Records
I have loop displaying certain records depending on an id number in my sql database. What i need to do using asp is total all the numbers in one of the fields and display that as a response.write.
Inserting New Records To DB
I have created an online database for a school project, and everything WAS going fine until today. I created the add record page and for some reason, whenever i try to add the records to the database THIS error message comes up: Code:
Inserting Records
what the best way to update a ms access database from an asp page is.I have a db with 3 different tables,these tables are bound to each other via the relationships. On my asp page,I want to create one page where the user would enter in information and hit submit.The problem I have though is that how do I have only one button that will update information from 3 or more tables all at once?
Inserting More Than One Records
I am working on a project, and now I am experiencing a problem to insert multiple records at a time. My form is designed so that a user can insert multiple input (in several text fields). What is the best strategy to handle this? the number of fields are created randomly (I will use innerHTML in Javascript to present text field randomly on my form). I have tried to use google using the following keyword: "inserting multiple records using ASP", but the result page did not satisfy me.
Inserting Records
although it seems that the database is updated the data doesn't pass to the table...Just the autonumber is increasing in the database without insering the records (the other records remain blank...like submitting nothing).. Code:
Deleting RS Records Using Loop Iteration
Can I loop through a recordset and with each record, see if the value of a field is higher than 5. If it higher than 5, just delete that record, not the whole record set and continue the loop. I am accustomed to using a sql statement to selecting an entire recordset based on similar criteria and deleting the whole recordset in one swoop, but not this time. Code:
For Next Loop Issue With Empty Records
I am having an issue with a For Next Statement... I have a query that is looking up Company ID's where Specific ID exists... across multiple Access DB's Data is return ok, but if a specific ID does not exists a DB, the query loops the last Result in the NEXT statement for subsequents columns... My question how do i get the FOR NEXT Statement to look at NULLS and return ZERO instead of loops the last results...
Inserting Multiple Records
Im having a hared time with this, im trying to update multiple records in a database from a form. The form display all records from a search query and then the user selects whether to post the record of put the record on hold (two fields in the database). Now everywhere I have looked I only see examples which update the records by using counts but I could end up with any number of records. I thought that using a loop would be an idea to get passed this.
Inserting Multiple Records
Does anyone know how to upload or insert multiple records into a MS Database. I've been trying to figure this out all day with little success. It seems that their should be a way to upload a txt file or csv file and have all the records go into the dbase.
Inserting Multiple Records
i've created a page that displays a list of records with a checkbox next to each. I'd like to give my users the option of selecting multiple checkboxes then clicking submit which will insert a new record for each of the checked option. for example: Code:
Inserting Script Every Two Records
i have a page where all my company records are disaplayed, now two records fit per page, so what i want to try and do is place a page break and a title after every two records so when its printed it prints them two per page with a a title on everypage.
Error Inserting Records
When I submit the Application form, various records are inserted into 10 different tables. The master table is taking the correct ID number, but the rest of the tables are showing "0" as the ID. Can anyone throw a light on what could be going wrong ?
Loop For Displaying Multiple Records From An SQL Query?
I have an ASP page where I want to display the 3 most recent records within a database using a SQL query. The problem is that my page which output the results is only showing the first most recent record and not the two past ones aswell. Am I right in thinking that might be related to the 'loop' function? I know that my SQL code is fine as I have previewed the results from the code and they are correct. Code:
Inserting And Updating Records In Classic Asp
I am having trouble getting records to insert and update properly. This is not a consistent problem. It is intermittent. The page will allow me to correctly update 2 or 3 times generally, however after that it will double up the data in the insert and update. Here is the code I am using. Code:
Systematic Updating Of Records Depending On Amount Of Records In Another Table
The problem concerns 2 tables, cart_products and cart_shoppingcart. Cart_products contains all the product data (eg, prices, product's key name, etc), but most importantly, it contains the quantity of stock (prod_quantity) for each item. cart_shoppingcart contains all of the user's items in their shoppingcart, including those that are part of an (customer) order; these have the order_number to differentiate from those that aren't in any order (their Order_number is 'no_order', the others have the order number). Now, what I want to do is this: For every item in the order (ie, every entry in cart_shoppingcart that matches the username and order number), take the quantity (x) the customer is ordering, then take the quantity of stock remaining (y), then subtract x from y to create the new stock level (z) and update the appropriate record in cart_products with z (all this with SQl preferably). I was thinking of using a Do while loop, but realised that it wouldn't work as I'd have to use several SQL statements and then I'd run into a problem the minute ASP reads "objrec.movenext".
Grouping Records Within Another Group Of Records
I have an Access database with two fields that I would like to group by. The two fields are location and department. Field names are "Location" and "DeptName". I have the code correct for grouping by location. That code looks like this: Code:
Do While Loop?
I have a case statment like select case code case "01" ups_desc = "OPTION1." case "02" ups_desc = "OPTION2." case "03" ups_desc = "OPTION3" case "07" ups_desc = "OPTION4" case "08" ups_desc = "OPTION5 " case "11" ups_desc = "OPTION6" case "12" ups_desc = "OPTION7" end select I then have table called "users" which has the following id UserID Code now the trick I want to loop through the recordset of the user tables and populate a drop down where the code from the case and the user table are the same. Something like do while rs("code") = code <option> This then is populated based upon the loop(I have this code)</option> loop
Loop
I need to insert recordes into a db based upon a number returned in a form Somerthing like AddRecords = Request.Form("NumberOfRecords") Count = 0 if Count < AddRecords Then Do while Count.eof SQL Code.... Count = Count + 1 Count.move next Loop End If
Loop
I have some arrays multiples arrays like (,1,2,3,4,5,6,9) and (lucas, john,nathan,mary,..) I was trying to have a output like a list ID Name 1 mary 2 John .. .. However how can i do this? I tried "for each" loop but it repeats one field twice
How To Loop
i have 2 tables (A & B) with date records now i loop table A and then table B, the output will be table A in the front and table B in the back.how can i make the output show by date in both tables altogether? do i need to combine tables before but the number of records is over 100K which may spend a lot of processing power?
Asp Loop
on my classifieds site i would like to create a simple ads system. i currently have the ads site made but need some advice. on my classifieds site i would like to display the ads down the left hand side. however i dont want to over display ads. if there is not many items listed i only want a small amount of adverts shown on the left hand side. however if there is lots listed i would like quite a few adverts listed. otherwise i would have a big list of adverts and only a small number of items listed making a big blank space on my page. i am guessing this would have to be a loop or something. the code i am using to show the text links is <%=adurl%>
For Loop
I am using a for loop in one of my asp page. Could someone let me know if I can do the for loop as follow: [code]<% for i = 1 to 5 %> my html code my html code my html code <% Next i %> instead of [code]<% for i = 1 to 5 Response.Write "<input name = 'id'"&i&" type='text' value = "&id& ">" Next i %>
More Than 1 Do Loop
I am using ASP and need a DO LOOP to get some info back from the db. but the asp reads the first do loop but does not read the second one ......
While Loop
is there any function or statements that work the same as the 'break' statement in C++ language? for example: While Not rs.EOF If rs("LoginID") = userId Then break 'what shd i use for ASP??? Else rs.movenext
Loop
I'm trying to perform a loop to display the contents of my DB, the only issue is that I would only like to display 10 results maximum this is relatively easy but what happens if there are less than 10 results in the DB. If I was going to do a : Do Until objRS.EOF Then it would display the full records, likewise if i put a counter on the loop then it will run into errors if I have less records than the count.
For Loop
got a problem Given: Title No_of_Download A 6 B 8 C 9 D 10 E 0 F 1 I wanna display 5 result from the above table starting from the most no of download, meaning Title E will not be display. How do i do it using a For Loop?
Loop Within A Loop
im writing some script to add records to my db. but if a value thats about to be added exists, then dont add that record.for example: if i want to add 7 records to my db with the values 1 - 7, but the db already has 3, 5 and 7, then it should only add 4 new records (1, 2, 4 and 6). i have a record returning all records form my db, and an array with the values i want to add. i want to loop through my recordset of all existing entries, then for each loop, start another loop to see if the value exists, and if it doesnt , then add a new record.
For Loop Or Do While Loop
How to use the for loop or do while loop to create the age range from 10 -100 to let the user to select from the form object - list/menu by using asp? The coding below is just a concept. For example Response.Write("<select name=""select"">") for (a=0; a<101; a++) ( Response.Write("<option value=""" & age & """>" & age & "</option>") ) Response.Write("</select>")
If Then Else Loop
I'm trying to create a page where images are displayed based on an id in a sql table (basically its an unlit candle until a value in the id field exists). I'm not getting an error with my code below - but its not working right either. Code: <% If rs("my_id")="2" Then Response.Write "<img src=""images/07.jpg"" width=""56"" height=""97"" alt="lit candle">"Else Response.Write "<img src=""images/UNLIT_07.jpg"" width=""56"" height=""97"" alt=""unlit candle"">" End If %> ...
Sub And For Next Loop
I have a SUB which has input variables. If I run it once its okay, but I need to include it in a for....next loop. Can this be done ? for i=0 to 100 call mySub(arr(0,i)) next sub mySub(var) .....code end sub
RS Loop
I am getting this error: Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Microsoft Access Driver]Numeric value out of range (null) /database/data_entry.asp, line 90 Line 90 is shown below... // count the total records by iterating through the recordset for (rsProducts_total=0; !rsProducts.EOF; rsProducts.MoveNext()) { <---- Line 90 rsProducts_total++; } This is an access database, connected to via a DSN. Any help will be muchly appreciated! I'm stuck on this one.
For Next Loop
I'm using three loops on a page and would like to set the loops individually to start at either 0 or -1 based on a condition. As an example, I would want the loop to start at either -1 as shown or 0. Dim r For r = --1 to Session("TotalRowsF") code... Next Or, based on the condition it could be Dim r For r = 0 to Session("TotalRowsF") code... Next
ASP Loop
I can display some text 5 times using a loop and i want to pass those printed values to another page when i clicked send button.
Loop D Loop
I'm trying to give the variable sStart a new name on each loo EG sStart1 = value1 sStart2 = value however the following piece of code doesn't work set oNodes=xml.selectNodes("/Project/Tasks/Task/Start" for each oNode in oNode sStart=oNode.tex response.write("<BR>" for i=0 to 10 response.Write(sStart(i) nex next
Next Or Loop?
I've been coding now for around 3 years. A year ago, I inherited a forum from a friend who didn't have the time to run it anymore. It's an old, very old, version of the WebWiz template, much modified. So modified in fact that upgrading to a newer version is impracticle, the best I can do is add features that you'd expect a forum to have these days. Code:
Do While Loop / ASP
Here's my problem (aside from the fact that I'm a newbie.) I'm using ASP to call an Access database with four separate tables. The first three are working perfectly. The fourth is a little more tricky. I'm pulling the information based on a registration number (entered via a form). In the fourth table, each registration number is listed multiple times with production information for each year and quarter. For example: (reg number, year, quarter, # lbs, amount) A008374 - 2001 - Q1 - 840 - 232 A008374 - 2001 - Q2 - 520 - 164 A008374 - 2001 - Q3 - 8256 - 3368 . . . etc. I want to use a Do While...Loop (print the information while the registration # is equal to the one entered) to print out the information for each entry. Code:
Comparison Using Loop
I am doing a scheduling system. The concept i have but i am weak in my programming, therefore i hope that u all can help me on this. i have a capacity (uph x shift x 7.17) and orderperday (total orderqty per month / total shift per month) the thing that i am not sure in is, i want to do a comparison it is becoz there is a capacity limit per day. i cannot afford 2 produce overlimit. so if the orderperday > capacity then orderperday - capacity = balance. balance will be bring forward to the next day to produce. then the comparison will be done again. i am not certain on how to do the looping in this context.
Problem With 'For' Loop
I am running a for loop but i dont know how many time i will need it to loop and the data may vary, is it VITAL that the syntax is For x = 0 to 5 or is there a way of stating to complete the action until the end of the table. I was thinking of using the EOF function but i am using a variable x to group the data together in the table so it doesnt go all muddled up. Any suggestions?
Jmail Loop
I am some what new to asp and programing. I have put together this code, so I can send out a mailing list to some users. The code looks and seams to run fine. But I dont receive any test messages during when I execute it. it's like the SMTP sever is not sending the emails....
For Each Loop Problem?
I am facing a problem in For each loop. I am getting values of the selected records from a form and trying to add it the database. CardSt=request.form("CrdStatus") for each CustomerId in Request.form("CustomerId") SqlStr="Update Customer set CardStatus= '"& CardSt & "' where Customer_id= "& CustomerId & " " cn.Execute SqlStr next ------------------------ For example I am trying to update 5 records out of 20. The customerIds are selected as check boxes from previous page. The cardstatus are drop down menus. So if i select 5 customerId check boxes out of 20 records, there will be 5 customerIds coming to this page and all the cartstatus values. The cardstatus values has no reference to the CustomerIds.
Do Until Loop Problem
I am trying to display records from a recordset after sql statement: <% sqlstr ="SELECT horsename FROM tblhorseentry WHERE trackname = '" & request.querystring("trackname") & "' and racedate = '" & request.querystring("racedate");" Set rs1 = Server.CreateObject("ADODB.Recordset") rs1.Open sqlstr,pConn,3 do until rs1.eof response.write left(rs1("horsename"),14) rno = rno + 1 rtg = rtg + 1 rs1.Close set rs1 = nothing loop %> ...but when I test the querystring link going into the page with the asp scripting, I do not see my horsename(s) display; it just echoes a blank webpage.
Time Loop
I am trying to get an asp working which will loop every 30 minutes. Then take a copy of one file from one server and place the date/time now() in front of the file before writing it to another.I tried it on my laptop at work just by checking if the file exsits but seem to have trouble encoding with unc paths. [code] <% Set fs=Server.CreateObject("Scripting.FileSystemObject") If (fs.FileExists("viper3 vdatainfosystv2502vinfotv32.exe"))=true Then Response.Write("The system is offline for essential data load") Else Response.Write("File exists.") End If set fs=nothing %> [code]
|