Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > MS Technologies ( ASP, VB, C#, .NET )
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 11-17-2004, 12:30 PM   #1 (permalink)
buchannon
Registered User
 
buchannon's Avatar
 
Join Date: Nov 2004
Posts: 43
buchannon is on a distinguished road
ASP login with access

I'm trying to create a very simple logon using a number kids receieve at our school called the "bearnumber"

I found a sample ASP code to work with access and got everything working. I just had a few questions. If someone doesn't mind answering or pointing me in the direction of a good tutorial, that would be uber.

In this part of the script, what is going on?
Quote:
strSQL = "SELECT * FROM tblLoginInfo " _
& "WHERE bearnumber='" & Replace(Request.Form("bearnumber"), "'", "''") & "';"

Set cnnLogin = Server.CreateObject("ADODB.Connection")
cnnLogin.Open("DRIVER={Microsoft Access Driver (*.mdb)};" _
& "DBQ=" & Server.MapPath("login.mdb"))

Set rstLogin = cnnLogin.Execute(strSQL)

If Not rstLogin.EOF Then
Also, in this line, what do all the ''',''' & ";" mean?
Quote:
& "WHERE bearnumber='" & Replace(Request.Form("bearnumber"), "'", "''") & "';"
__________________
buchannon is offline   Reply With Quote
Old 11-17-2004, 12:50 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
asp is a little different to the c style syntax (javascript,php,c,c++,java,perl) trained people.

asp ends a line of code with a new line. if you want your line of code to keep going, then you use the '_' at the end of the line.

'&' is used as a concatinator. the equivalent to '+' in javascript, or '.' in php.

that code is createing a sql string: select * from tblLoginIfno where bearnumber='<bearnumber-sent-from-form>'

the next line create the connection to the database, login.mdb

Set rstLogin = cnnLogin.Execute(strSQL) <-- this line executes the query to the database.

the last line is just saying .. "do this if there is a result" or more accurately, "if we are not at the end of the rstLogin record set, then do this .."

hth
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 11-17-2004, 01:15 PM   #3 (permalink)
buchannon
Registered User
 
buchannon's Avatar
 
Join Date: Nov 2004
Posts: 43
buchannon is on a distinguished road
Ah thanks man, that helped a lot. I came across a simple SQL tutorial but couldn't figure out with that '_' was doing...

Another question:
I have 3 columns. One for fname (firstname), lname (last name), and bearnumber (the students bear number). If after that if statement it did find a matching bearnumber, how could I make the page display the first and last name associated with that bear number?

Thank you for the help sde!
__________________
buchannon is offline   Reply With Quote
Old 11-17-2004, 01:38 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
hmm .. not exactly sure .. i don't use asp much. check this link out, .. it will probably help.

http://www.w3schools.com/ado/ado_recordset.asp

Code:
<% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" set rs=Server.CreateObject("ADODB.recordset") rs.Open "Select * from Customers", conn for each x in rs.fields response.write(x.name) response.write(" = ") response.write(x.value) next %>
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 11-19-2004, 09:11 AM   #5 (permalink)
buchannon
Registered User
 
buchannon's Avatar
 
Join Date: Nov 2004
Posts: 43
buchannon is on a distinguished road
Ok I can get it to display only the line of the table I want, but now I can't figure out how to edit out one of the variables. I want it to display 'Welcome (fname) (lname)' but right now it is naming all three variables: (fname) (lname) and (bearnumber)

I was thinking of putting a counter in the loop but it's not working.
Quote:
dim counter
counter = 0
response.write("<center>Welcome ")

do until rs.EOF
for each x in rs.Fields
Response.Write(x.value & " ")
counter = counter + 1
if counter = 2 then stop
next
__________________
buchannon is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues with Access creed Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 7 08-23-2004 09:55 AM
MySQL vs MS Access Epsilon PHP 5 05-24-2004 02:28 PM
Access denied for user: '@192.168.0.71' (Using password: NO) infinite_root PHP 11 04-28-2004 05:30 PM
ASP Recordsets rdove ASP Classic 0 03-08-2004 06:30 PM
Printing and Viewing Access Reports (VBA) rdove VB 6 0 02-24-2003 02:19 PM


All times are GMT -8. The time now is 06:36 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle