473,385 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 1845

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
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
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...
7
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...
1
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...
1
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...
4
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...
4
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....
13
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...
2
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') ...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.