Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Correct userid , wrong username

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
my project is all about a login system. Whenever i click login, it will display their particulars. But i have this problem, whenever i click submit button, they will only show the first row username of the database. And the userid is correct but the username is wrong. So how to make it possible that it will show the correct userid and username correctly and display it nicely.

The coding is provided below:




<%

Dim h, name
Dim SQL,Rs2
Dim Rs, Con, ConnString
Dim Con1


Set Rs=Server.CreateObject (&quot;ADODB.CONNECTION&quot;)
ConnString=&quot;driver={sql server};server=o6f2e1;database=user;DSN=localserver;PWD=;UID=sa;&quot;
Rs.Open ConnString

SQL = &quot;select * from info &quot;

Set Con=Rs.Execute (SQL)

SQL= &quot;select * from Course&quot;

Set Con1=Rs.execute (SQL)

h = hour(now)


Do until Con.fields(&quot;NameID&quot;)

If h < 12 then
Response.Write (&quot;<p>&quot;)
response.write(&quot;Good Morning!<p>&quot; & Con.Fields(&quot;NameID&quot;))
Response.Write (&quot;</p><p>&quot;)
Response.Write (&quot;Your Modules is &quot; & Con1.fields(&quot;Modules&quot;))
Response.Write (&quot;</p><p>&quot;)
elseif h <18 then
Response.Write (&quot;<p>&quot;)
response.write(&quot;Good Afternoon!<p>&quot; & Con.Fields(&quot;NameID&quot;))
Response.Write (&quot;</p><p>&quot;)
else
Response.Write (&quot;<p>&quot;)
response.write(&quot;Good Night! <p>&quot; & Con.Fields(&quot;NameID&quot;))
Response.Write (&quot;</p><p>&quot;)

Loop

End if


%>
 
Hi

There is a bit of a problem with your loop. Do until con.fields(&quot;nameID&quot;) should not execute as the field exists in the recordset (true) so it won't hit the loop (or it will hit it once - I can't remember and I am off my main PC)

Also, even if the loop was working fine you are not iterating through the recordset (conn.movenext()) and you are pulling every record in the info table. If you are only after one record returned you should use:

&quot;Select * from info where nameID=&quot; & nameIDvariable

This will then prevent you from even needing the loop. Derren
[The only person in the world to like Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top