1. Make sure your web.config file has the following:

<add name="dev" connectionString="server=devserver.redstone;database=mydb;uid=myuser;pwd=mydevpw" />
<add name="qa" connectionString="server=qaserver.redstone;database=mydb;uid=myuser;pwd=myqapw" />
<add name="prod" connectionString="server=prodserver.redstone;database=mydb;uid=myuser;pwd=myprodpw" />

2. Make sure the code where you make your DB connection has the following code below. Please note, this was written in C#

SqlConnection conn = null;
string SQLServer = null;
// Figure out which tier this server is
string webServerTier = Environment.GetEnvironmentVariable("TIER");
// Connection String to Database
String connString = ConfigurationManager.ConnectionStrings[webServerTier].ToString();
conn = new SqlConnection(connString);
// set up my SQL command
SqlCommand cmd = new SqlCommand("SELECT FName, LName FROM NAMES", conn);
// SQL Reader to read the information obtained from the SQL command
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read() == true)
String FName = (string)rdr["FName"];
String LName = (string)rdr["LName"];
// do something with the LName and FName variables, etc.
conn = null;
catch (Exception ex)
ErrorMessage.Text = ex.Message;
ErrorMessage.Visible = true;

How do I make a database connection to MySQL in ASP?

<title>ASP - MySQL Connection</title>
<center><p><strong>ASP - MySQL Connection</strong></p>
Dim sConnection, objConn , objRS
sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER={Enter MySQL server name here}; DATABASE={Enter database name here}; UID={Enter database username here};PASSWORD={Enter database password here}; OPTION=3"
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = objConn.Execute("SELECT lastname, firstname FROM test ORDER By lastname")
While Not objRS.EOF
Response.Write objRS.Fields("firstname") & " " & objRS.Fields("lastname") & "<br>"
Set objRS = Nothing
Set objConn = Nothing

How do I create an Email Web Form in ASP?

<% @language=VBScript %>
‘Dimension variables
Dim objCDOSYSCon
‘Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject(“CDO.Message”)
Set objCDOSYSCon = Server.CreateObject (“CDO.Configuration”)
‘Out going SMTP server
objCDOSYSCon.Fields(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “smtp.purdue.edu”
objCDOSYSCon.Fields(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
objCDOSYSCon.Fields(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
objCDOSYSCon.Fields(“http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout”) = 60
‘Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = “youremailaddress@purdue.edu”
objCDOSYSMail.To = ” youremailaddress@purdue.edu”
objCDOSYSMail.Subject = “Insert Subject Here”
objCDOSYSMail.HTMLBody = “Insert Message Here”
‘Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing

Note: Email addresses should never be passed from the From Section. If recipient email addresses vary, pass a variable that can be translated to an email address in the Post Section.

Why not put the email address in the Form Section?

Spammers use robots to gleen email addresses from HTML code. Keeping email addresses out of the Form Section will remove one method that spammers find your email address.

Allowing an email address to be passed to the Post Section allows unfriendlies do wells to use your re-mailer to send email for unintended uses.

View Log Files