Jump to content

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 post
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 post
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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...