Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 15th, 2004, 12:28 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Database Write and Email

My boss here at work is trying to create a website for users in which they can enter information into a form and when submitted.. the information is

1. Written to a database (that can be viewed of course)
2. The information or a confirmation is emailed to the I.T. staff.

Is there a way to do this? Please try to keep your response as dumbed down as possible. I just feel it will save on more questions and the fact that I've not dealt with ASP and all in awhile.
  #2 (permalink)  
Old September 15th, 2004, 02:03 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Sure, you can do it. Database access is easy in ASP, and emails can be done through SMTP server or a third-party component.

Brian
  #3 (permalink)  
Old September 15th, 2004, 02:39 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well I know it is possible.. I'm saying how would I go about doing it :-) Unfortunately, my boss is trying to set it up quick using Frontpage and all it does is create a Web Bot but it won't allow for both writing information to the database and also emailing the same information to him letting him know something was submitted. Thanks for the early reply Brian :)
  #4 (permalink)  
Old September 15th, 2004, 02:53 PM
Friend of Wrox
 
Join Date: May 2004
Location: Ardabil, Ardabil, Iran.
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Default

you can send a mail using your asp.net page for confirmation and using hosted site smtp email engine .
using tis code you can send email using asp.net
include this directive to your page.
Code:
<%@Import Namespace="System.Web.Mail" %>

MailMessage msgMailRespond = new MailMessage();
MailMessage msgMail = new MailMessage();
UTF8Encoding utf8 = new UTF8Encoding();
msgMail.BodyEncoding= utf8 ;
msgMail.To ="anyone@anyserver.com";
msgMail.From =from.Text;
msgMail.Subject =strSubject.Text;
msgMail.BodyFormat = MailFormat.Html;
string strBody="<div style=\"font-family:tahoma,zar,arial,yagut ,font-size:14\">"+strMessageBody.Text;
 strBody+="<br></div>";
msgMail.Body = strBody;
SmtpMail.Send(msgMail);
YoOrD.

Beauty Is not on the face
Beauty is on the heart
--<<Ghibran Khalil>>--
  #5 (permalink)  
Old September 15th, 2004, 03:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

I don't know how I could send any code and "dumb it down"... I also have been working with ASP.NET and don't have any code samples.

Sorry,

Brian
  #6 (permalink)  
Old September 16th, 2004, 09:52 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

We don't use ASP.NET it would just be plain jane ASP, VBScript, Javascript. Well okay send code and don't dumb it down. I can probably make heads and/or tails of it :-)
  #7 (permalink)  
Old September 16th, 2004, 09:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi inquiringminds,

If you have started off and face any problem in continuing with it/stuck up somewhere in the middle, may be you can post your problems here and we can help you resolve it. I am not sure, if you want someone to write the code for you and send it across.

Probably you can use google search for finding something related to that you are looking for. You will find a lot from there.

Cheers!

_________________________
- Vijay G
Strive for Perfection
  #8 (permalink)  
Old September 20th, 2004, 01:25 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay I'm starting this out and I'm basing it on code I got from a ASP forum site. This is just to set up the form and test that it writes to a MS-Access Db.. but I keep getting the following

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
/ncmh/form_ac.asp, line 29

here is the code on the Insert line and below

data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("questionstest.mdb")
sql_insert = "INSERT INTO questionstest (firstname, lastname, agency, phone, email, urgency, contact, question, date) VALUES " &_
"('" & mgfirstname & "', '" & mglastname & "', '" & mgagency & "', '" & mgphone & "', '" & mgemail & "', '" & mgurgency & "', '" & mgcontact &_
"', '" & mgquestion & "', '" & mgdate & "')"

'Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_insert
  #9 (permalink)  
Old September 20th, 2004, 01:27 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I meant to say that I've tried a few things mostly dealing with omitting or supplying quotation marks around the VALUES area. The form comes up but this page does not work. Line 29 is the con.Execute... line.
  #10 (permalink)  
Old September 21st, 2004, 06:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

usually the easiest way to sort out probs with malformed SQL is to add
Response.Write sql_insert
Response.End

before the line that errors. That way you can see exactly what SQL is going to be sent to the db. Often it's then obvious what the problem is.

Try that and if you can't figure it out then post the SQL here and we'll take a look.

rgds
Phil


Similar Threads
Thread Thread Starter Forum Replies Last Post
Write to a database MMJiggy62 Beginning VB 6 3 August 24th, 2006 12:11 AM
how to write email.aspx page hunzian78@yahoo.com ASP.NET 2.0 Basics 0 July 19th, 2006 03:50 AM
How to write email client qazi_nomi Classic ASP Basics 2 June 9th, 2004 04:01 AM
How to write Recieving Email in ASP qazi_nomi Classic ASP Basics 1 June 5th, 2004 01:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.