Send Form results to database error

From: Pam Hatfield (pam_at_manytalents.com)
Date: 04/27/04


Date: Mon, 26 Apr 2004 21:08:47 -0400

Please help! Here's the error:

        

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified

/email.asp, line 100

Where exactly is line 100? I've arrowed down 100 lines but that doesn't
seem to be where the error is!
Here's the email.asp page code:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Thank you for submitting your information</title>
<meta name="Microsoft Theme" content="iatse-fpg-black-tubes 1110, default">
<meta name="Microsoft Border" content="tlb, default">
</head>

<body>

<%

    '========================================================
    ' When you press ENTER in a text box, a carriage return
    ' is created. A carriage return is represented by a
    ' Chr(13). Because this information will be displayed
    ' as HTML, replace the carriage returns with
    ' the <br> tag.
    '========================================================
    Function ParseBody(strText)
        '=================================================
        ' This function replaces the Chr(13) with a <br>
        ' tag in whatever string is passed to it.
        '=================================================
        strText = Replace(strText, Chr(13), "<br>")
        ParseBody = strText
    End Function
   
   
    '========================================================
    ' Send results to the database.
    ' This portion of the page sends the information
    ' from the form to the Northwind sample database.
    '========================================================

    '========================================================
    ' Variable declaration:
    ' myConnString = Connection string to database.
    ' myConnection = The database connection object.
    ' mySQL = The query string to be used.
    '========================================================
    Dim myConnString
    Dim myConnection
    Dim mySQL

    '========================================================
    ' Set up connection string. When you created the
    ' database connection in FrontPage called "Sample",
    ' FrontPage created an Application variable in the
    ' Global.asa file called "Sample_ConnectionString".
    '
    ' Use that connection string by populating the
    ' myConnString variable with the value contained
    ' in the Application variable.
    '
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' You can modify this to work with your database by
    ' changing "Sample_ConnectionString" to reflect your
    ' FrontPage database connection. For example, if you
    ' defined your connection in FrontPage as "Database1",
    ' you would change the following line to this:
    ' myConnString = Application("Database1_ConnectionString")
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
myConnString = Application("IATSEEmail_ConnectionString")
   
 
    '========================================================
    ' When you are using custom ASP to set up a connection to
    ' a database, you use a Connection to connect to the
    ' database. The following line creates that connection and
    ' assigns the myConnection variable to contain the
    ' Connection object.
    '========================================================
    Set myConnection = Server.CreateObject("ADODB.Connection")
   
    '========================================================
    ' After the connection has been created, open it so that
    ' information can be written to the database. To do
    ' that, use the Open method and pass it the connection
    ' string that you defined earlier.
    '========================================================
    myConnection.Open myConnString
   
    '========================================================
    ' This is the SQL string that queries the database.
    ' In this example, Request.Form("[form_field]")
    ' pulls information from the form and populates the SQL
    ' string with it.
    '
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    ' You can modify this SQL string to work with your own
    ' database by following this format. Pay special
    ' attention to the fact that spaces are not optional.
    ' -------------------------------------------------------
' mySQL = "INSERT INTO [your_table_name] "
    ' mySQL = mySQL & "([database_field_names]) "
    ' mySQL = mySQL & "VALUES ('[form_field_names]')"
    ' -------------------------------------------------------
    ' For more information about this, see the
' Customizing the Database Page section of this document..
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    mySQL= "INSERT INTO IATSEEmail "
mySQL= mySQL & "(FirstName,LastName,Address,City,State,Zip) "
    mySQL= mySQL & "VALUES ('" & Request.Form("FirstName") & "','"
mySQL= mySQL & Request.Form("LastName") & "'"
    mySQL= mySQL & ",'" & Request.Form("Address") & "'"
    mySQL= mySQL & ",'" & Request.Form("City") & "','"
mySQL= mySQL & Request.Form("State") & "','"
    mySQL= mySQL & Request.Form("Zip") & "')"
   
    '========================================================
' Execute the connection with the SQL string.
' This runs the SQL string against the database and inputs
' the information.
'=========================================================
    myConnection.Execute mySQL
   
    '=== Close the connection.
    myConnection.Close
           
    '=== Set the connection equal to Nothing.
'=== This frees resources used by it.
    Set myConnection = Nothing
   
   
 

    '===================================================================
    ' Send the results to e-mail.
    ' Use CDONTS to create and send a message based on information
    ' entered into the form. The following lines compose and send
    ' the e-mail.
    '===================================================================
 
'====================================================================
' Set up variables:
' myCDONTSMail = A CDONTS mail object.
' strFrom = A string containing the source e-mail address.
' strTo = A string containing the destination e-mail address.
' strSubject = A string containing the subject of the e-mail.
' strBody = A string containing the body of the e-mail.
'====================================================================
Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
Dim strBody

    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    ' Assign the source e-mail address. Change this to your e-mail
    ' address.
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
strFrom="Pam@manytalents.com"

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Assign the destination e-mail address. In this example, get the
' e-mail address from the form field called "EMail".
' You can customize this by removing the EMail form field and
' changing the following line to this:
' strTo="example@microsoft.com" ß Change this to your e-mail
' address.
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
strTo="pam@manytalents.com"

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' The following line is the subject of the e-mail. You can change
' this to a subject that is customized to your liking.
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
strSubject = "E-mail Update"

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' The following lines create the body of the message. This can be
' anything you want it to be.
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
strBody="The following information was submitted:" & Chr(13)
strBody = strBody & Request.Form("FirstName") & " "
strBody = strBody & Request.Form("LastName")
strBody = strBody & Chr(13) & Request.Form("Address") & Chr(13)
strBody = strBody & Request.Form("City") & Chr(13)
strBody = strBody & Request.Form("State") & Chr(13)
strBody = strBody & Request.Form("Zip") & Chr(13)
strBody = strBody & Chr(13) & "Thank you for submitting your data."

'====================================================================
' The SET statement creates the CDONTS mail object in preparation
' for sending the e-mail message.
'====================================================================
Set myCDONTSMail = CreateObject("CDONTS.NewMail")

'====================================================================
' The following line sends the mail message using the source e-mail,
' destination e-mail, subject, and body that were defined earlier.
'====================================================================
myCDONTSMail.Send strFrom,strTo,strSubject,strBody

    '=== Set the CDONTS mail object to NOTHING to free resources.
Set myCDONTSMail = Nothing

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' For information about how to customize the rest of this page, see the
' Customizing the Confirmation Page section of this document. Sections
' that are discussed in the Customizations section are delimited
' by percent signs.
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%>
<p><font face="Verdana" color="#FF0000"><b>Thank you for submitting your
information!<br>
</b></font><font face="Verdana" size="2">You will receive an e-mail
shortly.&nbsp; The e-mail was sent using the following
information:</font></p>
<b><font face="Verdana" size="2">Sent To: <%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   Response.Write Request.Form("EMail")
  '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%>
<br>
From&nbsp;&nbsp;&nbsp; : Microsoft PSS Sample Page</font>
<p><font face="Verdana" size="2">Subject: E-mail Update</font></p>
<p><font face="Verdana" size="2">Content: <%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Call the ParseBody function and pass the strBody string to it.
' This will replace the Chr(13) characters with <br> tags in the HTML.
Response.Write(ParseBody(strBody))
  '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%>
</font></p>
<hr noshade size="1" style="color: #000000">
<p>&nbsp;</p>
</b>&nbsp;</body>

</html>

Your help is greatly appreciated!!!

-- 
Pam
"How we spend our days is, of course, how we spend our lives." - Annie Dillard


Relevant Pages

  • Re: Changing Connection String programmatically
    ... Connection strings of different years can be stored in app.config ... is declared in MyDataset.Designer.cs as private, ... every year we will create new database. ... If you are storing connnection string information related to additional ...
    (microsoft.public.sqlserver.connect)
  • Re: User count
    ... Dim colUsers as New Collection ... Dim sCompName as string ... or back it up, or something, then take a look at the use of the "Connection ... Create a table in the front-end database, ...
    (microsoft.public.access.formscoding)
  • Re: [VW 7.3.1] ODBCConnection
    ... I played around with a few combinations on the connection string and ... with a trusted SQL Server connection. ... there are differences for database connects. ... > any database specific odbc drivers. ...
    (comp.lang.smalltalk)
  • Re: Installer - Custom Textboxes in UI problem
    ... > void Install function. ... I've tested it by writing the string out to a text ... > intended, a ADO.Net Connection String. ... > throw new InstallException("The database conection information is not ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Drag/Drop/Upload Functionallity
    ... Friend Function GetData(ByVal strSQL As String, ... Dim myConnString As OleDbConnection = New ... ' Close the connection and destroy our connection objects ...
    (microsoft.public.dotnet.languages.vb)