472,137 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,137 software developers and data experts.

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 1752

"MrHelpMe" <cl********@hotmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.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********@hotmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.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********@hotmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.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********@hotmail.comwrote in message
news:11*********************@i3g2000cwc.googlegro ups.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********@hotmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.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********@hotmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Mike R | last post: by
3 posts views Thread by Tcs | last post: by
7 posts views Thread by Brian | last post: by
13 posts views Thread by PinkBishop | last post: by
2 posts views Thread by paulmitchell507 | last post: by

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.