salman.pirani 0 Posted August 29, 2012 Author Report 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 Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 sory my internet is create prblem thts why there many messges typed Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 i got it whts u are saying but i dnt knw how to do whts changes should i change in the codes Quote Link to post Share on other sites
justsomeguy 1,135 Posted August 29, 2012 Report Share Posted August 29, 2012 After you build the query, and before you send it to the database, print it out. This shouldn't be very complicated. You have one line where you define the query, and another line where you send it to the database. Between those lines you need to print it out. Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 like this response.write(sql="SELECT pt FROM Customers WHERE eid=444") <%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")response.write(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 %> Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 its giving "false" after exceution Quote Link to post Share on other sites
justsomeguy 1,135 Posted August 29, 2012 Report Share Posted August 29, 2012 Response.write(sql) after you build it. Build it first, then print it. Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 it simply printing the query like text SELECT pt FROM Customers WHERE eid='444' but am am writing in asp sql="SELECT pt FROM Customers WHERE eid='" & Request.Form("id") & "'" means the problem is after that rite <%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") & "'"Response.write(sql)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 %> Quote Link to post Share on other sites
justsomeguy 1,135 Posted August 29, 2012 Report Share Posted August 29, 2012 If this query works: SELECT pt FROM Customers WHERE eid=444 and this one doesn't: SELECT pt FROM Customers WHERE eid='444' then it looks like the problem is the quotes. Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 wow great its working so nice of u love u for that thanks alot god bless u ill try it to shows more filed then if i will have any query i will bother u again...thanks Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 just one thing more <%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 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 %> Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 in this code response.write("<th>" & x.name & "</th>") x.name is picking the name mention in database if i write any name instead of x.name so it is writing the same name in evry column head i want i will mention name in code andafter the code execute it will show the name i write not the head mention in data base Quote Link to post Share on other sites
justsomeguy 1,135 Posted August 29, 2012 Report Share Posted August 29, 2012 I'm not sure what you're asking, but look at the reference for a field object: http://www.w3schools.com/ado/ado_ref_field.asp When it does a loop like this: for each x in rs.Fields Then it sets x to each field object. So in the first loop it is going through all of the fields and printing the names, and in the second loop it goes through and prints the values of each field. The reference shows the other properties that the field object has (x.type, x.attributes, etc). Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 its showing thiswhen i write programme instead of x.name <table border="1" width="100%"> <tr> <th>programme</th><th>programme</th> </tr> <tr> <td>w</td> <td>ww</td> </tr> <tr> <td>w</td> <td>ww</td> </tr> <tr> <td>ss</td> <td>sss</td> </tr> <tr> <td>ss</td> <td>sss</td> </tr> </table> Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 i wnt that i first colum heading should be programme then in 2 column i should show date like this Quote Link to post Share on other sites
justsomeguy 1,135 Posted August 29, 2012 Report Share Posted August 29, 2012 If you want to specify your own column names then remove that loop and write whatever column names you want. Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 the link doest help my query its showing the codes i hv already incorporated Quote Link to post Share on other sites
salman.pirani 0 Posted August 29, 2012 Author Report Share Posted August 29, 2012 but the loop help me to print the all row mention in the data base against the value given if i will remove the loop i will only print 1 row rite ? Quote Link to post Share on other sites
justsomeguy 1,135 Posted August 29, 2012 Report Share Posted August 29, 2012 Remove the loop where it prints the column names, and write whatever you want there. Keep the loop where it prints the data. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.