Jump to content

fetch asp


salman.pirani

Recommended Posts

my query is i want that a client type a id in text box and then on the submit button the asp will fetch the all data from the server placed in other filed against the id which mention in the text box so what changes i want to do in the code html

<form action="fetch.asp" method="post">em id <input name="id" type="text" /></form>

asp

<%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "c:/webdata/northwind1.mdb"set rs = Server.CreateObject("ADODB.recordset")sql="SELECT pt, pdate FROM Customers"rs.Open sql, conn%><table border="1" width="100%"><tr><%for each x in rs.Fieldsresponse.write("<th>" & x.name & "</th>")next%></tr><%do until rs.EOF%><tr><%for each x in rs.Fields%><td><%Response.Write(x.value)%></td><%nextrs.MoveNext%></tr><%looprs.closeconn.close%>

am getting so much help from this forum am really thankfull to this forum and the people

Link to comment
Share on other sites

i made these changes in the codekindly tell me what should i write in the WHERE heghlited below in yellowto extract id from the txt

<%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "c:/webdata/northwind1.mdb"dim idid=Request.Form("id")set rs = Server.CreateObject("ADODB.recordset")sql="SELECT pt , q1a FROM Customers WHERE eid=[color=#ffd700]444[/color]"rs.Open sql, conn%><table border="1" width="100%">   <tr>   <%for each x in rs.Fields	 response.write("<th>" & x.name & "</th>")  'response.write("<th>" & "programme" & "</th>")   next%>   </tr>   <%do until rs.EOF%>	 <tr>	 <%for each x in rs.Fields%>	   <td><%Response.Write(x.value)%></td>	 <%next	 rs.MoveNext%>	 </tr>   <%loop   rs.close   conn.close   %></table>

Link to comment
Share on other sites

"Request.Form" is not part of the query, you need to stop the query string, add the value from the form, and then finish the query. Just writing "Request.Form" inside of a string doesn't cause the value that points to to go into the string. There are examples of using the & operator to join strings here: http://www.tizag.com/vbscriptTutorial/vbscriptstrings.phphttp://www.landofcode.com/vbscript-tutorials/vbscript-strings.php

Link to comment
Share on other sites

Look at the links I referred you to. If you're going to be writing code you need to understand strings. If you want to combine a string with another value you use the & operator, like I said. sql="SELECT pt , q1a FROM Customers WHERE eid='" & Request.Form("id") & "'"

Link to comment
Share on other sites

That's fine, but you're not going to be able to learn how to program by having someone tell you. You'll need to research for yourself. I can't sit here and tell you everything you need to know, I don't have time for that. You even have an example in your code about how to do this: response.write("<th>" & x.name & "</th>") If it's not working you need to post your code and say exactly what it is or is not doing.

Link to comment
Share on other sites

yeah u r rite but a right support will take u to the result and i knw u r busy but with it u r very helpfull full code

<%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "c:/webdata/northwind1.mdb"set rs = Server.CreateObject("ADODB.recordset")sql="SELECT pt FROM Customers WHERE eid='" & Request.Form("id") & "'"rs.Open sql, conn%><table border="1" width="100%">   <tr>   <%for each x in rs.Fields	 response.write("<th>" & x.name & "</th>")   next%>   </tr>   <%do until rs.EOF%>	 <tr>	 <%for each x in rs.Fields%>	   <td><%Response.Write(x.value)%></td>	 <%next	 rs.MoveNext%>	 </tr>   <%loop   rs.close   conn.close   %>

error An error occurred on the server when processing the URL. Please contact the system administrator.If you are the system administrator please click here to find out more about this error.

Link to comment
Share on other sites

with it am trying my best am reading many more link but i m not getting the result Here is the setup ineed.Text Box: User enters in customer idButton: User clicks button to display information about the customer in next asp page ASP Page: will show the data in other columns against the id mention in the text box

Link to comment
Share on other sites

i knw the code to show the error {if err<>0 thenResponse.Write("Error code " & err)elseanswer end if} but i dnt know where should i placed this in the code i have tried palcing it but its not giving me the answer

<%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "c:/webdata/northwind1.mdb"set rs = Server.CreateObject("ADODB.recordset")sql="SELECT pt FROM Customers WHERE eid='" & Request.Form("id") & "'"rs.Open sql, conn  %><table border="1" width="100%">   <tr>   <% if err<>0 then   Response.Write("Error code " & err)else   for each x in rs.Fields	 response.write("<th>" & x.name & "</th>")   next%>   </tr>   <%do until rs.EOF%>	 <tr>	 <%for each x in rs.Fields%>	   <td><%Response.Write(x.value)%></td>	 <%next	 rs.MoveNext%>	 </tr>   <%loop   rs.close    end if   conn.close     %>

Link to comment
Share on other sites

I don't see a problem with the code. The link you provided earlier goes to a page that explains how to setup IIS to run classic ASP. If it's giving you that link then it sounds like you don't have IIS set up correctly. Or maybe there's a problem with the database query. Try to run a simple classic ASP script without any database connection and see if the server will run that.

Link to comment
Share on other sites

If it works when you hardcode the query then it sounds like there's a problem with the query, so print out the query you're trying to run and find a way to run that query directly on the database to see what the problem is.

Link to comment
Share on other sites

my iis is rum corectly i have checked it by runing my applications see if i run code like this

<%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "c:/webdata/northwind1.mdb"set rs = Server.CreateObject("ADODB.recordset")sql="SELECT pt FROM Customers WHERE eid=444"rs.Open sql, conn  %><table border="1" width="100%">   <tr>   <% for each x in rs.Fields	 response.write("<th>" & x.name & "</th>")   next%>   </tr>   <%do until rs.EOF%>	 <tr>	 <%for each x in rs.Fields%>	   <td><%Response.Write(x.value)%></td>	 <%next	 rs.MoveNext%>	 </tr>   <%loop   rs.close   conn.close     %>

so its working

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...