Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
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 :colbert:
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);

Adbot
ADBOT LOVES YOU

Eararaldor
Jul 30, 2007
Fanboys, ruining gaming since the 1980's

Ah thanks. BTW problem solved anyway.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply