- Eararaldor
- Jul 30, 2007
-
Fanboys, ruining gaming since the 1980's
|
I'm not entirely sure if this is the right place to post this but I'll give it a shot. Basically creating a c# web application. After they submit information into the database, a email is needed to be dispatch displaying the contents that was just added.
Anyway I get this error and its anoying me
Format of the initialization string does not conform to specification starting at index 0.
It shows at the connection string.
code:using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Net.Mail;
using System.Globalization;
using BEC.WebOrder;
/////start of app
public partial class Apply2 : System.Web.UI.Page
{
private string block1;
private string block2;
private string block3;
private void GetDataFromDatabase()
{
SqlConnection scon = new SqlConnection("<%$ ConnectionStrings:Myconnectionstring %>");
SqlCommand scmd = new SqlCommand("SELECT Column1, Column2, Column3 FROM table", scon);
SqlDataReader sdr;
try
{
scon.Open();
sdr = scmd.ExecuteReader();
sdr.Read();
block1 = sdr["column1"].ToString();
block2 = sdr["column2"].ToString();
block3 = sdr["column3"].ToString();
}
catch (Exception ex)
{
throw new Exception("Error occured: " + ex);
}
finally
{
scon.Close();
}
}
/////Get Message
private string GetMessage()
{
GetDataFromDatabase()
string message = block1 + "<br />" + block2 + "<br />" + block3;
return message;
}
//////End get message
protected void sendButton_Click(object sender, EventArgs e)
{
//When button is clicked, sqldatasource is inserted into the database. Status label displays a message confirming.
SqlDataSource.Insert();
statusLabel.Text = "Your Booking has been sent. Your receive a Email notifying you of its status.";
///Code to send of email to(fakefake.com)
MailMessage message = new MailMessage();
MailAddress SendFrom = new MailAddress("Fake@fake.com");
message.From = SendFrom;
message.To.Add("Fakefake.com");
message.Bcc.Add("Fakefake.com");
message.Subject = "Read me";
///GetMessage makes the Get Message section above work
message.Body = GetMessage();
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Host = "My webserver";
client.Send(message);
|
#
¿
Mar 7, 2008 12:41
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 4, 2024 05:58
|
|
- Eararaldor
- Jul 30, 2007
-
Fanboys, ruining gaming since the 1980's
|
Ah thanks. BTW problem solved anyway.
|
#
¿
Mar 7, 2008 16:38
|
|