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 sory my internet is create prblem thts why there many messges typed Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted August 29, 2012 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. Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author 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 %> Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author Share Posted August 29, 2012 its giving "false" after exceution Link to comment Share on other sites More sharing options...
justsomeguy Posted August 29, 2012 Share Posted August 29, 2012 Response.write(sql) after you build it. Build it first, then print it. Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author 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 %> Link to comment Share on other sites More sharing options...
justsomeguy Posted August 29, 2012 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. Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author 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 Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author 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 %> Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted August 29, 2012 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). Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author 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> Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted August 29, 2012 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. Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author Share Posted August 29, 2012 the link doest help my query its showing the codes i hv already incorporated Link to comment Share on other sites More sharing options...
salman.pirani Posted August 29, 2012 Author 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 ? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 29, 2012 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. 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