11. januar 2001 - 20:27
Der er
23 kommentarer og 1 løsning
link to DISTINCTROW
Hey There I have a database that i use it works fine however I would like to in an asp page to have a form where if the input of the input field can be found in the database then it displays only that distinct id in the database ( a bit like a user or password login ) something where i have a form like this <form method=\"POST\" action=\"userinfo.asp?id=<%=id%>\"> <input type=\"text\" name=\"user\" size=\"20\"> <input type=\"submit\" value=\"Search\" name=\"Action\"> and then in userinfo.asp page have a database connection like this <% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"adresse.mdb\") strSQL = \"SELECT Id, navn ,adresse ,telefon FROM adresse WHERE id=<%=user%> %> am i totally wrong or close or please help Guzzie (nubie) as normal sorry bout the english
Annonceindlæg fra Computerworld
11. januar 2001 - 20:30
#1
or maybe a connection like this <% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"adresse.mdb\") strSQL = \"SELECT DISTINCTROW Id, navn ,adresse ,telefon FROM adresse WHERE id=<%=user%> %> hmmm :)
11. januar 2001 - 20:32
#2
Something like this ? strSQL = \"SELECT DISTINCT Id, navn ,adresse ,telefon FROM adresse WHERE id=\" & user & \";\"
11. januar 2001 - 20:32
#3
<% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"adresse.mdb\") strSQL = \"SELECT DISTINCTROW Id, navn ,adresse ,telefon FROM adresse WHERE id=\'\" & request(\"id\") & \"\'\" %>
11. januar 2001 - 20:34
#4
This <%=user%> won\'t work, instead you just concentate the two string with \" & user & \" (my prev. comment should\'ve been an answer)
11. januar 2001 - 20:34
#5
This <%=user%> won\'t work, instead you just concentate the two string with \" & user & \" (my prev. comment should\'ve been an answer)
11. januar 2001 - 20:35
#6
guzzie:> i completely forgot the \'\' around it .. sorry tpiil:> a little correction: strSQL = \"SELECT DISTINCTROW Id, navn ,adresse ,telefon FROM adresse WHERE id=\'\" & request(\"user\") & \"\';\"
11. januar 2001 - 20:36
#7
And by the way .. why don\'t you use SELECT DISTINCTROW * FROM .. instead of specifiying each field to select ?
11. januar 2001 - 20:36
#8
thanks i will try that it sounds good ;) i´ll write a bit later have go out for a while guzzie :)
11. januar 2001 - 20:52
#9
ok heres how it looks now <html> <body> <form method=\"POST\" action=\"userinfo.asp?id=<%=id%>\"> <input type=\"text\" name=\"navn\" size=\"20\"> <input type=\"submit\" value=\"Search\" name=\"Action\"> </body> </html> then the userinfo.asp page <% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"adresse.mdb\") strSQL = \"SELECT DISTINCTROW Id, navn ,adresse FROM adresse WHERE id=\'\" & request(\"user\") & \"\';\" Conn.Execute (SQLstmt) Set rs = conn.Execute(SQLstmt) %> <html> <body> <table> <tr> <td><%=rs(\"navn\")%></td><td><%=rs(\"adresse\")%></td> </tr> </table> <% conn.Close Set conn = nothing Set SQLstmt = nothing %> </body> </html> thanks for your help guzzie
11. januar 2001 - 20:56
#10
ok corection for userinfo.asp <% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"adresse.mdb\") strSQL = \"SELECT DISTINCTROW * FROM adresse WHERE id=\'\" & request(\"user\") & \"\';\" Conn.Execute (SQLstmt) Set rs = conn.Execute(SQLstmt) %> <html> <body> <table> <tr> <td><%=rs(\"navn\")%></td><td><%=rs(\"adresse\")%></td> </tr> </table> <% conn.Close Set conn = nothing Set SQLstmt = nothing %> </body> </html> :) sniff Guzzie
11. januar 2001 - 21:01
#11
<html> <body> <form method=\"POST\" action=\"userinfo.asp\"> <input type=\"text\" name=\"navn\" size=\"20\"> <input type=\"submit\" value=\"Search\" name=\"Action\"> </body> </html> then the userinfo.asp page <% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"adresse.mdb\") strSQL = \"SELECT DISTINCTROW Id, navn ,adresse FROM adresse WHERE (user LIKE \'%\" & request(\"navn\") & \"%\');\" Conn.Execute (SQLstmt) Set rs = conn.Execute(SQLstmt) if not (rs.BOF Or rs.EOF) Then %> <html> <body> <table> <tr> <td><%=rs(\"navn\")%></td><td><%=rs(\"adresse\")%></td> </tr> </table> <% conn.Close Set conn = nothing Set SQLstmt = nothing %> <% else %> Ingen brugere med det navn :( </body> </html> <% end if %>
11. januar 2001 - 21:02
#12
Navnet på kolonnen skal du nok rette for der skrev jeg user! er ikke så god til engelsk :)
11. januar 2001 - 22:38
#13
Hey there again Guys I tried the advice you gave all that happens is that I get \"siden kan ikke vises\" heres how it looks now first page is <html> <body> <form method=\"POST\" action=\"userinfo.asp\"> <input type=\"text\" name=\"navn\" size=\"20\"> <input type=\"submit\" value=\"Search\" name=\"Action\"> </body> </html> then the userinfo.asp page looks like this <% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"adresse.mdb\") strSQL = \"SELECT DISTINCTROW Id, navn ,adresse FROM adresse WHERE (navn LIKE \'%\" & request(\"navn\") & \"%\');\" Conn.Execute (SQLstmt) Set rs = conn.Execute(SQLstmt) if not (rs.BOF Or rs.EOF) Then %> <html> <body> <table> <tr> <td><%=rs(\"navn\")%></td><td><%=rs(\"adresse\")%></td> </tr> </table> <% conn.Close Set conn = nothing Set SQLstmt = nothing %> <% else %> Ingen brugere med det navn :( </body> </html> <% end if %> hope some can help heres some more points if need be i can send you a link to the page or mail you the script.... Guzzie Sniff Nubi ;(
11. januar 2001 - 22:40
#14
link the page :)
11. januar 2001 - 22:46
#15
11. januar 2001 - 22:48
#16
in userinfo.asp: Conn.Execute (SQLstmt) to Conn.Execute (strSQL)
11. januar 2001 - 22:50
#17
<% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"adresse.mdb\") strSQL = \"SELECT DISTINCTROW Id, navn ,adresse FROM adresse WHERE (navn LIKE \'%\" & request(\"navn\") & \"%\');\" Conn.Execute (strSQL) Set rs = conn.Execute(strSQL) if not (rs.BOF Or rs.EOF) Then %> <html> <body> <table> <tr> <td><%=rs(\"navn\")%></td><td><%=rs(\"adresse\")%></td> </tr> </table> <% conn.Close Set conn = nothing %> <% else %> Ingen brugere med det navn :( </body> </html> <% end if %>
11. januar 2001 - 23:18
#18
Thank you Thank you Thank you yippee !!!!!! thanks so much for your help Guzzie :)
11. januar 2001 - 23:21
#19
hehe så lidt!
11. januar 2001 - 23:41
#20
/hey tpiil :) it works great but even if i only right part of the navn then it can find the userinfo is there any way to change (navn LIKE \'%\" & request(\"navn\") & \"%\');\" the LIKE part to something more precise ? Guzzie
11. januar 2001 - 23:44
#21
den er faktisk lige meget med like men det kan bruges til søgninger, vent lidt så laver jeg om på koden!
11. januar 2001 - 23:49
#22
ved ikke helt om det her virker: <html> <body> <% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"adresse.mdb\") strSQL = \"SELECT DISTINCTROW Id, navn ,adresse FROM adresse WHERE navn=\'\" & request(\"navn\") & \"\';\" Conn.Execute (strSQL) Set rs = conn.Execute(strSQL) %> <table> <tr> <td><%=rs(\"navn\")%></td><td><%=rs(\"adresse\")%></td> </tr> </table> </body> </html> <% conn.Close Set conn = nothing %>
11. januar 2001 - 23:50
#23
thanks tpiil I tried to just remove the LIKE but it didnt work i dont want it to search just only that Id :) Guzzie ;)
11. januar 2001 - 23:52
#24
jesus you r good :) its works just perfect now you are 1 cool dude and i thank u again :) Guzzie
Kurser inden for grundlæggende programmering