p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP 3.0 (http://p2p.wrox.com/forumdisplay.php?f=27)
-   -   Database Write and Email (http://p2p.wrox.com/showthread.php?t=18438)

inquiringminds September 15th, 2004 12:28 PM

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.

bmains September 15th, 2004 02:03 PM

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

inquiringminds September 15th, 2004 02:39 PM

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 :)

yoord September 15th, 2004 02:53 PM

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>>--

bmains September 15th, 2004 03:25 PM

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

inquiringminds September 16th, 2004 09:52 AM

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 :-)

happygv September 16th, 2004 09:58 PM

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

inquiringminds September 20th, 2004 01:25 PM

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

inquiringminds September 20th, 2004 01:27 PM

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.

pgtips September 21st, 2004 06:33 AM

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


All times are GMT -4. The time now is 09:36 AM.

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