Jump to content

fetch asp


salman.pirani
 Share

Recommended Posts

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

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

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

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

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

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

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
 Share

×
×
  • Create New...