473,880 Members | 1,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to select and insert using asp

Hello experts,

O.k I give up on this. I have an LDAP query from asp working
correctly. It is returning data fine. Now I need to know how to take
this data and then submitt it into the database. Can this be done in
one page and is there any other way to do this without putting a submit
button on a page. Almost like a file that I can pass to the user and
he can click it to insert into a database. My way of do it is to
simply to put a submit button on the page and when the user hits submit
the values selected will go to the database. However the only thing on
this page is a submit(kinda useless).

This is part of my code
Expand|Select|Wrap|Line Numbers
  1. <form name="form1" method="post" action="ldap_second.asp">
  2.  
  3. <TABLE BORDER = 2>
  4. <TR><TD>Name</TD>
  5. <TD>Mail</TD>
  6. <TD>GivenName</TD>
  7. <TD>Address</TD>
  8. </TR>
  9.  
  10. <%
  11. Do Until objRecordSet.EOF%>
  12. <%
  13. Dim N
  14. Dim M
  15. Dim GN
  16. N = objRecordset("Name")
  17. M = objRecordset("Mail")
  18. GN = objRecordset("GivenName")
  19. SA = objRecordset("StreetAddress")
  20.  
  21. response.write "<TR>"
  22. response.write "<TD>" & N & "</TD>"
  23. response.write "<TD>" & M & "</TD>"
  24. response.write "<TD>" & GN & "</TD>"
  25. response.write "<TD>" & SA & "</TD>"
  26. response.write "</TR>"
  27. %>
  28. <%      objRecordSet.MoveNext
  29. Loop
  30. %>
  31. </TABLE>
  32. <p><input type="submit" value="Submit" name="B1</p>
  33.  
Now on my ldap_second how to I take the values and submit them to a
database. Your help is appreciated.

Oct 25 '06 #1
6 1875

"MrHelpMe" <cl********@hot mail.comwrote in message
news:11******** *************@i 3g2000cwc.googl egroups.com...
Hello experts,

O.k I give up on this. I have an LDAP query from asp working
correctly. It is returning data fine. Now I need to know how to take
this data and then submitt it into the database. Can this be done in
one page and is there any other way to do this without putting a submit
button on a page. Almost like a file that I can pass to the user and
he can click it to insert into a database. My way of do it is to
simply to put a submit button on the page and when the user hits submit
the values selected will go to the database. However the only thing on
this page is a submit(kinda useless).

This is part of my code
Expand|Select|Wrap|Line Numbers
  1. <form name="form1" method="post" action="ldap_second.asp">
  2. <TABLE BORDER = 2>
  3. <TR><TD>Name</TD>
  4. <TD>Mail</TD>
  5. <TD>GivenName</TD>
  6. <TD>Address</TD>
  7. </TR>
  8. <%
  9. Do Until objRecordSet.EOF%>
  10. <%
  11. Dim N
  12. Dim M
  13. Dim GN
  14. N = objRecordset("Name")
  15. M = objRecordset("Mail")
  16. GN = objRecordset("GivenName")
  17. SA = objRecordset("StreetAddress")
  18. response.write "<TR>"
  19. response.write "<TD>" & N & "</TD>"
  20. response.write "<TD>" & M & "</TD>"
  21. response.write "<TD>" & GN & "</TD>"
  22. response.write "<TD>" & SA & "</TD>"
  23. response.write "</TR>"
  24. %>
  25. <%      objRecordSet.MoveNext
  26. Loop
  27. %>
  28. </TABLE>
  29. <p><input type="submit" value="Submit" name="B1</p>
  30.  

Now on my ldap_second how to I take the values and submit them to a
database. Your help is appreciated.
Well, given that a form requires fields to be of any use (as you alluded to)
why not simply response.write the values into hidden form fields?

--
Mike Brind
Oct 25 '06 #2
Mike thanks for the reply. Anyway you could show me how to do that
with some sample code? Sorry still learning everything:)

Mike Brind wrote:
"MrHelpMe" <cl********@hot mail.comwrote in message
news:11******** *************@i 3g2000cwc.googl egroups.com...
Hello experts,

O.k I give up on this. I have an LDAP query from asp working
correctly. It is returning data fine. Now I need to know how to take
this data and then submitt it into the database. Can this be done in
one page and is there any other way to do this without putting a submit
button on a page. Almost like a file that I can pass to the user and
he can click it to insert into a database. My way of do it is to
simply to put a submit button on the page and when the user hits submit
the values selected will go to the database. However the only thing on
this page is a submit(kinda useless).

This is part of my code
Expand|Select|Wrap|Line Numbers
  1. <form name="form1" method="post" action="ldap_second.asp">
  2.  
  3.  <TABLE BORDER = 2>
  4.  <TR><TD>Name</TD>
  5.  <TD>Mail</TD>
  6.  <TD>GivenName</TD>
  7.  <TD>Address</TD>
  8.  </TR>
  9.  
  10.  <%
  11.  Do Until objRecordSet.EOF%>
  12.  <%
  13.  Dim N
  14.  Dim M
  15.  Dim GN
  16.  N = objRecordset("Name")
  17.  M = objRecordset("Mail")
  18.  GN = objRecordset("GivenName")
  19.  SA = objRecordset("StreetAddress")
  20.  
  21.  response.write "<TR>"
  22.  response.write "<TD>" & N & "</TD>"
  23.  response.write "<TD>" & M & "</TD>"
  24.  response.write "<TD>" & GN & "</TD>"
  25.  response.write "<TD>" & SA & "</TD>"
  26.  response.write "</TR>"
  27.  %>
  28.  <%      objRecordSet.MoveNext
  29.  Loop
  30.  %>
  31.  </TABLE>
  32.  <p><input type="submit" value="Submit" name="B1</p>
  33.  
Now on my ldap_second how to I take the values and submit them to a
database. Your help is appreciated.

Well, given that a form requires fields to be of any use (as you alluded to)
why not simply response.write the values into hidden form fields?

--
Mike Brind
Oct 25 '06 #3
Do it in the same way as you've written the table out using response.write.

Response.Write "<input type=""hidden"" ... etc

--
Mike Brind

"MrHelpMe" <cl********@hot mail.comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
Mike thanks for the reply. Anyway you could show me how to do that
with some sample code? Sorry still learning everything:)

Mike Brind wrote:
>"MrHelpMe" <cl********@hot mail.comwrote in message
news:11******* **************@ i3g2000cwc.goog legroups.com...
Hello experts,

O.k I give up on this. I have an LDAP query from asp working
correctly. It is returning data fine. Now I need to know how to take
this data and then submitt it into the database. Can this be done in
one page and is there any other way to do this without putting a submit
button on a page. Almost like a file that I can pass to the user and
he can click it to insert into a database. My way of do it is to
simply to put a submit button on the page and when the user hits submit
the values selected will go to the database. However the only thing on
this page is a submit(kinda useless).

This is part of my code
Expand|Select|Wrap|Line Numbers
  1. <form name="form1" method="post" action="ldap_second.asp">
  2. <TABLE BORDER = 2>
  3. <TR><TD>Name</TD>
  4. <TD>Mail</TD>
  5. <TD>GivenName</TD>
  6. <TD>Address</TD>
  7. </TR>
  8. <%
  9. Do Until objRecordSet.EOF%>
  10. <%
  11. Dim N
  12. Dim M
  13. Dim GN
  14. N = objRecordset("Name")
  15. M = objRecordset("Mail")
  16. GN = objRecordset("GivenName")
  17. SA = objRecordset("StreetAddress")
  18. response.write "<TR>"
  19. response.write "<TD>" & N & "</TD>"
  20. response.write "<TD>" & M & "</TD>"
  21. response.write "<TD>" & GN & "</TD>"
  22. response.write "<TD>" & SA & "</TD>"
  23. response.write "</TR>"
  24. %>
  25. <%      objRecordSet.MoveNext
  26. Loop
  27. %>
  28. </TABLE>
  29. <p><input type="submit" value="Submit" name="B1</p>
  30.  

Now on my ldap_second how to I take the values and submit them to a
database. Your help is appreciated.

Well, given that a form requires fields to be of any use (as you alluded
to)
why not simply response.write the values into hidden form fields?

--
Mike Brind

Oct 25 '06 #4
Thanks again Mike,

So now I got it working and the hidden variables are being passed over.
The code is as follows:
Expand|Select|Wrap|Line Numbers
  1. Dim oConn
  2. Dim sSQL
  3. Dim N
  4. Dim M
  5. Dim GN
  6. Dim SA
  7. Dim objRS
  8.  
  9. N=Request.Form("Name")
  10. M=Request.Form("Email")
  11. GN=Request.Form("GivenName")
  12. SA=Request.Form("StreetAddress")
  13.  
  14.  
  15. Set oConn = Server.CreateObject("ADODB.Connection")
  16. oConn.Open ("connection")
  17. 'set ObjRS = server.CreateObject ("ADODB.Recordset")
  18.  
  19. If Request.Form("SubmitButton") = "Submit" Then
  20.  
  21. Do While Not ObjRS.EOF
  22.  
  23. sSQL = "INSERT into Tablex (Name, Mail, GName,PostalCode)"
  24. sSQL = sSQL &  "VALUES ('" & N&"', '"& M&"', '" & GN&"', '" &
  25. SA&"')"
  26. oConn.Execute ssql
  27.  
  28. ObjRS.MoveNext
  29. Loop
  30. ObjRS.close
  31. set ObjRS = nothing
  32. oConn.close
  33. set oConn = nothing
  34. End If
  35. %>
  36.  
However, now I am receiving error:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Error Type:
  3. ADODB.Recordset (0x800A0E78)
  4. Operation is not allowed when the object is closed.
  5. /activedirectory/ldap_second.asp, line 22
  6.  
Any ideas? Thanks.


Mike Brind wrote:
Do it in the same way as you've written the table out using response.write.

Response.Write "<input type=""hidden"" ... etc

--
Mike Brind

"MrHelpMe" <cl********@hot mail.comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
Mike thanks for the reply. Anyway you could show me how to do that
with some sample code? Sorry still learning everything:)

Mike Brind wrote:
"MrHelpMe" <cl********@hot mail.comwrote in message
news:11******** *************@i 3g2000cwc.googl egroups.com...
Hello experts,

O.k I give up on this. I have an LDAP query from asp working
correctly. It is returning data fine. Now I need to know how to take
this data and then submitt it into the database. Can this be done in
one page and is there any other way to do this without putting a submit
button on a page. Almost like a file that I can pass to the user and
he can click it to insert into a database. My way of do it is to
simply to put a submit button on the page and when the user hits submit
the values selected will go to the database. However the only thing on
this page is a submit(kinda useless).

This is part of my code
Expand|Select|Wrap|Line Numbers
  1. <form name="form1" method="post" action="ldap_second.asp">
  2.  
  3.  <TABLE BORDER = 2>
  4.  <TR><TD>Name</TD>
  5.  <TD>Mail</TD>
  6.  <TD>GivenName</TD>
  7.  <TD>Address</TD>
  8.  </TR>
  9.  
  10.  <%
  11.  Do Until objRecordSet.EOF%>
  12.  <%
  13.  Dim N
  14.  Dim M
  15.  Dim GN
  16.  N = objRecordset("Name")
  17.  M = objRecordset("Mail")
  18.  GN = objRecordset("GivenName")
  19.  SA = objRecordset("StreetAddress")
  20.  
  21.  response.write "<TR>"
  22.  response.write "<TD>" & N & "</TD>"
  23.  response.write "<TD>" & M & "</TD>"
  24.  response.write "<TD>" & GN & "</TD>"
  25.  response.write "<TD>" & SA & "</TD>"
  26.  response.write "</TR>"
  27.  %>
  28.  <%      objRecordSet.MoveNext
  29.  Loop
  30.  %>
  31.  </TABLE>
  32.  <p><input type="submit" value="Submit" name="B1</p>
  33.  
Now on my ldap_second how to I take the values and submit them to a
database. Your help is appreciated.


Well, given that a form requires fields to be of any use (as you alluded
to)
why not simply response.write the values into hidden form fields?

--
Mike Brind
Oct 26 '06 #5

MrHelpMe wrote:
Thanks again Mike,

So now I got it working and the hidden variables are being passed over.
The code is as follows:
Expand|Select|Wrap|Line Numbers
  1. Dim oConn
  2. Dim sSQL
  3. Dim N
  4. Dim M
  5. Dim GN
  6. Dim SA
  7. Dim objRS
  8. N=Request.Form("Name")
  9. M=Request.Form("Email")
  10. GN=Request.Form("GivenName")
  11. SA=Request.Form("StreetAddress")
  12. Set oConn = Server.CreateObject("ADODB.Connection")
  13. oConn.Open ("connection")
  14. 'set ObjRS = server.CreateObject ("ADODB.Recordset")
  15. If Request.Form("SubmitButton") = "Submit" Then
  16. Do While Not ObjRS.EOF
  17.    sSQL = "INSERT into Tablex (Name, Mail, GName,PostalCode)"
  18.    sSQL = sSQL &  "VALUES ('" & N&"', '"& M&"', '" & GN&"', '" &
  19. SA&"')"
  20.    oConn.Execute ssql
  21. ObjRS.MoveNext
  22. Loop
  23. ObjRS.close
  24. set ObjRS = nothing
  25. oConn.close
  26. set oConn = nothing
  27. End If
  28. %>
  29.  

However, now I am receiving error:
Expand|Select|Wrap|Line Numbers
  1. Error Type:
  2. ADODB.Recordset (0x800A0E78)
  3. Operation is not allowed when the object is closed.
  4. /activedirectory/ldap_second.asp, line 22
  5.  

Any ideas? Thanks.
The insert is a one time deal. There's no reason to be looping through
it, as there's nothing to loop through (it's an INSERT, not a select).

The error is from "Do While Not ObjRS.EOF" because ObjRS has not been
opened.

Oct 26 '06 #6
I see. Thanks Larry for the response.
Larry Bud wrote:
MrHelpMe wrote:
Thanks again Mike,

So now I got it working and the hidden variables are being passed over.
The code is as follows:
Expand|Select|Wrap|Line Numbers
  1.  Dim oConn
  2.  Dim sSQL
  3.  Dim N
  4.  Dim M
  5.  Dim GN
  6.  Dim SA
  7.  Dim objRS
  8.  
  9.  N=Request.Form("Name")
  10.  M=Request.Form("Email")
  11.  GN=Request.Form("GivenName")
  12.  SA=Request.Form("StreetAddress")
  13.  
  14.  
  15.  Set oConn = Server.CreateObject("ADODB.Connection")
  16.  oConn.Open ("connection")
  17.  'set ObjRS = server.CreateObject ("ADODB.Recordset")
  18.  
  19.  If Request.Form("SubmitButton") = "Submit" Then
  20.  
  21.  Do While Not ObjRS.EOF
  22.  
  23.     sSQL = "INSERT into Tablex (Name, Mail, GName,PostalCode)"
  24.     sSQL = sSQL &  "VALUES ('" & N&"', '"& M&"', '" & GN&"', '" &
  25.  SA&"')"
  26.     oConn.Execute ssql
  27.  
  28.  ObjRS.MoveNext
  29.  Loop
  30.  ObjRS.close
  31.  set ObjRS = nothing
  32.  oConn.close
  33.  set oConn = nothing
  34.  End If
  35.  %>
  36.  
However, now I am receiving error:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  Error Type:
  3.  ADODB.Recordset (0x800A0E78)
  4.  Operation is not allowed when the object is closed.
  5.  /activedirectory/ldap_second.asp, line 22
  6.  
Any ideas? Thanks.

The insert is a one time deal. There's no reason to be looping through
it, as there's nothing to loop through (it's an INSERT, not a select).

The error is from "Do While Not ObjRS.EOF" because ObjRS has not been
opened.
Oct 26 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
1494
by: Mike R | last post by:
Hi, I cant figure out how to do this.... for example: Select name from mytab order by col1 could return Mike
3
6477
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I COULD be wrong... :) I've tried the access group...twice...and all I get is "Access doesn't like ".", which I know, or that my query names are too long, as there's a limit to the length of the SQL statement(s). But this works when I don't try to...
7
4109
by: Brian | last post by:
Hello all - I am trying to Insert a new record to an Access 2002 database. Following the insert, I need to obtain the primary key of the inserted row (person_ID) which is an Autonumber field. I am using the following code (obtained from MSDN) to do this, but for some reason a value of 0 is returned. Why is 0 returned???? Dim newID As Integer = 0
1
3693
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into "access_log", the referential integrity triggers generate these queries: SELECT 1 FROM ONLY "public"."application_type" x
1
5480
by: suslikovich | last post by:
Hi all, I am getting this error when insert values from one table to another in the first table the values are varchar (10). In the second they are datetime. The format of the data is mm/dd/yyyy to be easily converted to dates. The conversion in this case is implicit as indicated in SQL Server documentation. Here is my query: INSERT INTO Campaign (CampaignID, Name, DateStart, DateEnd, ParentID, ListID) SELECT ...
4
2454
by: satish | last post by:
Values of two columns in two different tables--presentation using select Hi Everyone, i have two tables in the database . One is called address table and one is adressPhone Table. Below is the sample of those two tables
4
4294
by: Andrew S | last post by:
Hello Mr. Expert: - I have 3 tables in mysql in MyISAM table format, I am using mysql4.0 on freebsd5.3 - producttbl, productdetailentbl, pricetblN - they all have "productid" as the Primary KEY. there are less than 300,000 records in each table - when I ran the statement select productname from productdetailentbl left join producttbl on productdetailentbl.productid=producttbl.productid left join pricetblN on...
13
5814
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table CatalogImage where imgID also needs to be placed. Below is my code behind to carry the catID using the Select @@Identity and insert imgID to the bridge table. No data is being entered into the bridge table.
2
2858
by: rshivaraman | last post by:
CREATE TABLE RS_A(ColA char(1), ColB varchar(10)) INSERT INTO RS_A VALUES ('S', 'shakespeare') INSERT INTO RS_A VALUES ('B', 'shakespeare') INSERT INTO RS_A VALUES ('P', 'shakespeare') INSERT INTO RS_A
2
5611
by: paulmitchell507 | last post by:
I think I am attempting a simple procedure but I just can't figure out the correct syntax. My asp (classic) page runs a SELECT query to obtain dates and ID's from 2 tables uSQL = "SELECT cal_date, holiday_ID from Calendar, holiday_tbl WHERE (((calendar.cal_Date) Between . And .)) And Email_sent=0 AND Staff_ID=" & Staff_ID This works fine.
0
9926
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11093
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
10715
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...
1
10811
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7951
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
7105
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
5778
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...
1
4596
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
3
3220
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.