Click to See Complete Forum and Search --> : sql select statement need help urgent
trisolve
11-30-2003, 02:44 AM
Does asp allow this?
strSQL="SELECT Customers.Country, Customers.City, CustomerFROM Customers;"
Because the field name has a space in between, how can I use them in my query? e.g Contact Name has a space, how do i put it in the sql query above inorder to execute and get the results. Thanks a lot, i need to solve this immediately.
Daniel Klann
11-30-2003, 06:17 AM
Hello,
You can just surround the field name with square brackets ([ ]) e.g.
strSQL = "SELECT [Contact Name] FROM Customers;"
Hope that helps you out,
Daniel
trisolve
11-30-2003, 01:30 PM
Thanks a lot daniel. My another question is since I am new to asp, I need to develop a website with standard database features. Here is what I need:
Main page will display all the customer's name along with their id. Assuming the field of customer's name is cusname and field of id is cusid. With each record displayed from the database onto the web, will have a view detail link to it. If the user clicks on that link, it should take him/her to a new page where the rest of the data will be shown. I can't figure out how to do that. How do i send a value with a new page and act accordingly? Help!!
simflex
11-30-2003, 02:09 PM
Search this forum.
I posted a code that will do exactly what you are asking about awhile back.
trisolve
11-30-2003, 02:31 PM
simflex it would be great if you could give me a link or more details like the subject of the topic. Thanks for your response.
simflex
12-01-2003, 12:30 PM
I will put together the code again for you and I will let you when I am done.
simflex
12-02-2003, 09:55 AM
As promised, here is what you asked for.
CustInfo.asp
--------------
<%
Response.Buffer = True
' Connection String
Dim connStr
connStr = "DSN=YourDSN"
%>
<html>
<head>
<title>Inserts Images into Database</title>
<style>
body, input, td { font-family:verdana,arial; font-size:10pt; }
</style>
</head>
<body bgcolor=ffffff>
<table width="700" border="1" bordercolor="#000000" align="center" >
<%
' Recordset Object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
' opening connection
rs.Open "select * from yourTable ORDER BY YourTable.ID desc", connStr, 3, 4
If Not rs.EOF Then
Response.Write "<tr><td colspan=""7"" align=""center""><i>"
Response.Write "</td></tr>"
Response.Write "<td>Customer ID </td>"
Response.Write "<td>Click on any name below to see details</td></tr>"
While Not rs.EOF
Response.Write "<tr><td>"
Response.Write rs("cusID") & "</td><td>"
Response.Write "<a href=""Details.asp?ID=" & rs("cusID") & """>"
*Response.Write rs("CusName") & "</a></td><td></tr>"
rs.MoveNext
Wend
Else
Response.Write "No Record Found"
End If
rs.Close
Set rs = Nothing
%>
</table>
</body>
</html>
I will post the second page next post due to length constraint.
simflex
12-02-2003, 09:57 AM
Details.asp
------------
This page is still too long.
So I am attaching it.
If you have any question, ask!
You need to modify the codes and replace the fields I have in them with your own fields.