Results 1 to 2 of 2

Thread: New to ASP

  1. #1
    Join Date
    Dec 2005
    Posts
    8

    Unanswered: New to ASP

    Ok I'm creating a program, or going to try to create a program that we use to loan out parts. So I need the web file to be able to modify a database and display the results at the current time and E-mail when certain conditions are met. Poking around ASP with Access for the database seems to be the way to go. Any suggestions? I'm kinda new to programming but have picked up pretty fast on what I've learned so far. Also if ASP is the way to go can you recommend the best tutorial or guide book?? I also have access to Oracle9i . Thanks for any help!!!!

    Amy

  2. #2
    Join Date
    May 2005
    Posts
    39
    Howdy Amy,

    I really like ASP Faq, it has a lot of useful information that is laid out in a user-friendly way. Just type in something like "update database", "open connection" or anything like that, and it will display something useful for you.

    So I need the web file to be able to modify a database and display the results at the current time and E-mail when certain conditions are met.
    That doesn't sound too difficult, the only difficult part is being sure that your server can send email (you have to have CDO, CDONTS, or ASPEmail installed).

    A while ago, someone asked me how to write user comments into a database and display those comments on another page. I wrote a few scripts that outlined how to do that, and they make a good general reference for understanding how to manipulate a database (at least in so far as adding and displaying records). I've attached a ZIP file with the scripts to this post, and you can see a working version of the script here:
    http://www.fstdt.com/blog/cache/underemployed/index.asp

    Sending an email that meets certain conditions basically works like this:
    Code:
    <%
    Option Explicit
    Dim DSNName, Conn, RS, sql1
    Dim myMail
    
    	DSNName = "DRIVER=Microsoft Access Driver (*.mdb);DBQ="
    	DSNName = DSNName & Server.MapPath("mydata.mdb")		'##### Change this line to the location of your database #####
    	DSNName = DSNName & ";PWD=" & "mypass"					'##### Change this line to the password of your database #####
    	
    	Set Conn = Server.CreateObject("ADODB.Connection")		'creating Connection and Recordset objects
    	Set RS = Server.CreateObject("ADODB.RecordSet")
    	
    	sql1 = "Select * From your_table WHERE set conditions"	'You need to set some conditions for your WHERE clause. It is a prerequisite to know SQL before getting started, fortunately SQL isn't terribly difficult to learn.
    	Conn.Open DSNName
    	RS.Open sql1, Conn, 1, 1		'The "1, 1" means that we'll be opening the database in read-only mode,
    									'without making any modications to it.
    
    		if not rs.eof then			'EOF means "end of file", which happens if the SQL statement returns no results.
    									'We only enter the body of the IF if we find records that meet the defined conditions.
    
    			'We've found a record that matches criteria, so lets send and email
    			Set myMail=CreateObject("CDO.Message")		'Creating a mail object
    			myMail.Subject="Condition has been met"		'These are just generic fields, you should probably
    			myMail.From="mymail@mydomain.com"			'	replace them with more useful information.
    			myMail.To="someone@somedomain.com"
    			myMail.TextBody="Dear Sir or Madam, please pick up your part."
    			myMail.Send
    			set myMail=nothing
    		end if
    	RS.Close
    	Conn.Close
    	
    	set rs = nothing			'Make sure to clean up your variables and uninitializes objects
    	set conn = nothing
    %>
    If you want to access any of the fields from your table, use RS("fieldname") to get it. For instance, you can make the following modifications:

    Code:
    		if not rs.eof then			'EOF means "end of file", which happens if the SQL statement returns no results.
    									'We only enter the body of the IF if we find records that meet the defined conditions.
    
    			Dim clientName
    			clientName = RS("ClientName")
    			
    			'We've found a record that matches criteria, so lets send and email
    			Set myMail=CreateObject("CDO.Message")		'Creating a mail object
    			myMail.Subject="Condition has been met"		'These are just generic fields, you should probably
    			myMail.From="mymail@mydomain.com"			'	replace them with more useful information.
    			myMail.To="someone@somedomain.com"
    			myMail.TextBody="Dear " & ClientName & ", please pick up your part."
    			myMail.Send
    			set myMail=nothing
    		end if
    If you need any more help, let me know
    Attached Files Attached Files
    Last edited by YeahWhat; 04-23-06 at 06:20.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •