salman.pirani Posted August 27, 2012 Share Posted August 27, 2012 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 More sharing options...
justsomeguy Posted August 27, 2012 Share Posted August 27, 2012 You need to get the value from the form and add it into the query. http://www.w3schools.com/asp/asp_inputforms.asphttp://www.w3schools.com/ado/ado_query.asp Link to comment Share on other sites More sharing options...
salman.pirani Posted August 27, 2012 Author Share Posted August 27, 2012 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 More sharing options...
salman.pirani Posted August 27, 2012 Author Share Posted August 27, 2012 thnks for the reply actually i had already read the links mention by youbut i stuck in the line mention below sql="SELECT pt , q1a FROM Customers WHERE eid='Request.Form("id")'" the request.form is not working in the code Link to comment Share on other sites More sharing options...
justsomeguy Posted August 27, 2012 Share Posted August 27, 2012 "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 More sharing options...
salman.pirani Posted August 28, 2012 Author Share Posted August 28, 2012 thanks for the reply but i still not getting it how can i get the vaule in WHERE from the text box sql="SELECT pt , q1a FROM Customers WHERE eid='Request.Form("id")'" so the sql extract only the data mention in text box for the eid column Link to comment Share on other sites More sharing options...
justsomeguy Posted August 28, 2012 Share Posted August 28, 2012 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 More sharing options...
salman.pirani Posted August 28, 2012 Author Share Posted August 28, 2012 thnks sirthe links are so confusing am cant understand from this i always understand how u explainbut its still not working whts should i do next Link to comment Share on other sites More sharing options...
justsomeguy Posted August 28, 2012 Share Posted August 28, 2012 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 More sharing options...
salman.pirani Posted August 28, 2012 Author Share Posted August 28, 2012 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 More sharing options...
salman.pirani Posted August 28, 2012 Author Share Posted August 28, 2012 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 More sharing options...
justsomeguy Posted August 28, 2012 Share Posted August 28, 2012 There's no information in that error message that I can use to solve the problem, but that link goes to a page that talks about setting up IIS to run classic ASP, so maybe you don't have IIS configured correctly. Link to comment Share on other sites More sharing options...
salman.pirani Posted August 28, 2012 Author Share Posted August 28, 2012 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 More sharing options...
salman.pirani Posted August 28, 2012 Author Share Posted August 28, 2012 am only getting the value when i hardcore the id after the WHERE eid=... but i want that it show when a user enter a id in text box Link to comment Share on other sites More sharing options...
justsomeguy Posted August 28, 2012 Share Posted August 28, 2012 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 More sharing options...
justsomeguy Posted August 28, 2012 Share Posted August 28, 2012 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 More sharing options...
salman.pirani Posted August 29, 2012 Author Share Posted August 29, 2012 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 More sharing options...
salman.pirani Posted August 29, 2012 Author Share Posted August 29, 2012 but i want that it should pick the value in WHERE eid="from text box" Link to comment Share on other sites More sharing options...
justsomeguy Posted August 29, 2012 Share Posted August 29, 2012 If one query works and another one doesn't then you should print out the query you're telling it to run so that you can figure out what the problem is with the query. Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author Share Posted August 29, 2012 print out the query means Link to comment Share on other sites More sharing options...
justsomeguy Posted August 29, 2012 Share Posted August 29, 2012 Response.write the query so that you can see what you're sending to the database. If the database has a problem then the first step is to figure out exactly what you're telling it to do. Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author Share Posted August 29, 2012 can u suggest me where i but the code which will show me the whts the error umber its generating Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author Share Posted August 29, 2012 can u suggest me where i but the code which will show me the whts the error number its generating Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author Share Posted August 29, 2012 can u suggest me where i but the code which will show me the whts the error number its generating Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author Share Posted August 29, 2012 can u suggest me where i but the code which will show me the whts the error number its generating Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now