473,761 Members | 10,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't seem to crack updating a database

21 New Member
Hi it's me again, still working on the sam 5 minute problem so feeling kind of thick now.

I've dumped the idea of using a textarea for now and am using a textbox instead but am struggling when it comes to updating the database, I've tried several different methods and the one I'm currently battling with is as follows:
Expand|Select|Wrap|Line Numbers
  1. %
  2. set objconn=server.CreateObject("ADODB.connection")
  3. objconn.Mode=3
  4. objconn.Open ("DSN=localserver; User ID=blah; Password=blah; DATABASE=blah; APP=ASP Script")
  5. set rs2=objconn.execute ("SELECT EmailType from Grades_email_tbl")
  6. %> 
  7. <%
  8. Dim strEmailType
  9. strEmailType = Request.Form("Select1")
  10. %>  
  11. <form method="post" action="email.asp">
  12.  
  13. <select name=select1>
  14.  
  15. <%do while not rs2.eof %>
  16. <option><%=rs2(0)%></option>
  17. <%
  18. rs2.movenext
  19. loop
  20. rs2.Close 
  21. set rs2 = nothing
  22. %>
  23. </select>
  24. <% 
  25. Dim query
  26. query = "SELECT emailContents FROM Grades_email_tbl WHERE EmailType ='"&strEmailType&"'"
  27. set rs3 = server.createObject("ADODB.recordset")
  28. rs3.LockType =3
  29. rs3.open query, objConn
  30.  
  31. %>
  32. <input type=Submit value=Go! />
  33. &nbsp;
  34. &nbsp; &nbsp;
  35. Email type selected: <%=strEmailType%>
  36. <br /> 
  37. </form>
  38. <form method="post" action="emails_edit.asp" >
  39. <input name="no" type="hidden" value= <%=strEmailType%>>
  40. <table>
  41.  
  42. <input id="Text3" style="width: 200px" value=<%=rs3("emailContents")%> type="text" name="Text3" />
  43.  
  44. </table>
  45.  
  46. <input type="submit" name="action" value="Save">
  47. </form>
  48. <form name= "form2" method=post>
  49.  
  50. <tr><td align="center"  colspan="8">
  51.     &nbsp;<% 
  52.   ''Dim emailtxt
  53.   ''emailtxt= ("&Request.Form("Text1")")
  54.   ''Response.write bah("&Request.Form("emailtxt")&")
  55.   ''rs3("emailContents")=Request.Form ("emailtxt.value")
  56.   ''rs3.Update 
  57.   %><input type="submit" value="Send" name="submit1" style="width: 50px">
  58. </td></tr>
  59. </table>
  60.  
  61. </body></html>
  62.  
  63.  
  64. <%
  65. set objdb=nothing
  66. objconn.Close
  67. set objconn=nothing
  68. %>
Then the emails_edit.asp looks like:

Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript %>
  2. <%Option Explicit%>
  3.  
  4. <html>
  5. <body>
  6. <%
  7. Dim BolFound, rs4
  8. Dim con2
  9. set con2=server.CreateObject("ADODB.connection")
  10. con2.Open ("DSN=localserver; User ID=blah; Password=blah; DATABASE=blah; APP=ASP Script")
  11. set rs4=server.CreateObject("ADODB.recordset")
  12. rs4.LockType =3 
  13. rs4.Open "Grades_email_tbl", con2, &H0001
  14.  
  15. BolFound=false
  16.  
  17. Do while not (rs4.eof or BolFound)
  18.    If(strComp(rs4("emailType"), request("strEmailType"), vbtextcompare)=0) then
  19.      BolFound= True
  20.    Else 
  21.      rs4.movenext
  22.    End if
  23. Loop
  24. rs4("emailContents")= Request.Form("text3")
  25. rs4.update
  26. rs4.Close
  27. set rs4=nothing
  28. set Con2=nothing
  29. con2.close
  30.  
  31. %>
  32.  
  33. </body>
  34. </html>
  35.  
The select box works fine and when I hit the go button it loads the value of emailContents into my textbox, but when I his the Save button under the textbox I just get errors, the current one being a 'BOF or EOF is True" error so I'm guessing I'm not passing the values accross correctly, infact I've just confirmed that by trying to response.write r4("emailConten ts") so now I'm totally stumped
Oct 9 '07 #1
3 1796
Spoogledrummer
21 New Member
I think I've cracked it, a piece of code that didn't work when I tried it now seems to work.

Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript %>
  2. <%Option Explicit%>
  3.  
  4.  
  5. <%
  6. Dim rs4, con2, strEmailType, Query2
  7. strEmailType = request.Form("emails")
  8. Query2 = "Select * from grades_email_tbl where emailtype ='"&strEmailType&"'"
  9. set con2=server.CreateObject("ADODB.connection")
  10. con2.Open ("DSN=localserver; User ID=blah; Password=blah; DATABASE=blah; APP=ASP Script")
  11. set rs4=server.CreateObject("ADODB.recordset")
  12. rs4.LockType =3 
  13. rs4.Open Query2, con2, &H0001
  14. rs4("emailContents")= Request.Form("emailtxt")
  15. rs4.update
  16. rs4.Close
  17. set rs4=nothing
  18.  
  19. con2.close
  20. set Con2=nothing
  21. Response.Write "Your e-mail has been saved"
  22. %>
  23.  
Now all I have to do is get the second page to execute then return to the first page rather than a blank page, then figure out why another bit of code isn't e-mailing
Oct 10 '07 #2
jhardman
3,406 Recognized Expert Specialist
I'm glad you got it working. Are you saying you are still looking at how to redirect? The code for redirecting is
Expand|Select|Wrap|Line Numbers
  1. response.redirect "firstPage.asp"
The only problem with this is that this won't send any data to firstPage.asp. You can solve this (if you need data sent) by putting the data in session variables
Expand|Select|Wrap|Line Numbers
  1. for each x in request.form
  2.    session(x) = request.form(x)
  3. next
or in querystring
Expand|Select|Wrap|Line Numbers
  1. dim nextPage
  2. nextPage = "firstPage.asp?"
  3. for each x in request.form
  4.    nextPage = nextPage & x & "=" & server.urlEncode(request.form(x)) & "&"
  5. next
  6. nextPage = left(nextPage, len(nextPage)-1)
  7. response.redirect nextPage
Let me know if this helps.

Jared
Oct 11 '07 #3
Spoogledrummer
21 New Member
Thanks but I cheated, I put up a message on the second page confirming the e-mail message had been saved then put a button on it to direct the user back to the first page.
Oct 11 '07 #4

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

Similar topics

0
5357
by: Jim S. | last post by:
I'm having a horrible time simply inserting the date in a MySQL database through a Visual Basic program. I have a table, called "ORDERS"; "ID" is the primary key. I'm trying the insert the date, into the MySQL database, which is a DATETIME datatype. I must keep it DATETIME so it can be accessed via Microsoft Access. Here are two versions of the program. The first one fails, with the "Row cannot be located for updating. Some values may...
3
1326
by: Test Person | last post by:
Hi I'm having trouble with updating my database which is SqlServer. I'm using the update command and only the dataset is being changed not the actual row in the database. Best Regards
0
1274
by: Neoharuo | last post by:
I am working on a VB2003 project that accesses a SQL Server database. The first two forms (frmA, frmB) are almost identicle as far as the processes and data access and updating. I've set it up so that they both use shared functions to access and update the data but two their respective tables. Neither form is open at the same time. I set up just one SqlDataAdapter that has a mulit-table select that pulls in the entire database and uses just...
3
1407
by: Bucko | last post by:
How important do you guys feel locking a database is while updating/adding information? Do you do it with every app you make? Only very high volume (traffic) apps? I'm trying to decide if my app needs it.
1
2465
by: Luis Esteban Valencia | last post by:
Hello Everyone, Iam an intermediate ASP.Net programmer and iam facing a challenging task. I have a table in MS-SQL server database called 'Members'. The table has following fields... mem_id integer primary key lastname nvarchar(30) firstname nvarchar(30)
2
1675
by: Greg | last post by:
I'm using the Framework 1.1, so I don't have access to the new DataGridView object. What I'm wondering is, is there a really simple way to bind a plain datagrid to a database in such a way that changes made to cells in the datagrid call an update on the corresoonding data within a database? I've looked in vain for a really simple way to do this with minimal coding, but I'm coming to the conclusion that I will have to trap the events of...
13
7350
by: Nick 'The Database Guy' | last post by:
Hi Everyone, Does anyone out there have a crack for the security on a Access 2000 and or Access 2002-2003 (they could even be the same) database. I already have a crack for the database password on a Access 97 database, but it does not work on my later databases, and I'm not sure how this works with Access 97 workgroup security. Thank in advance.
0
1580
by: mathews9138 | last post by:
BadCopy Pro v3.81 crack Free download Crack. You Find all crack! Free download Crack. You Find all crack! Free download Crack. You Find all crack! Free download Crack. You Find all crack! http://wga-cracks.crackkey.net
0
1279
by: mathews9138 | last post by:
Game House crack Free download Crack. You Find all crack!
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.