Solved

Airline 4

Posted on 2012-04-06
5
296 Views
Last Modified: 2012-06-27
"<h3>Enrollment Sucessful</h3>

I have an error on this line.  I do not understand the newline errors.  How do I solve them?


Error      1      Newline in constant      C:\Course Technology\CIS Programming\ASP .NET Programming\Data Files\Chapter.09\Chapter\SkywardAviation\Registration.aspx.cs      65      17      C:\...\SkywardAviation\



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack
            && enrollmentForm.ActiveViewIndex == 0)
            hiddenPassword.Value = password.Text;
    }
    protected void Page_LoadComplete(
        object sender, EventArgs e)
    {
        if (Page.IsPostBack
            && enrollmentForm.ActiveViewIndex == 3)
        {
            SqlConnection dbConnection
                = new SqlConnection(
                    "Data Source=.\\SQLEXPRESS; AttachDbFilename=C:\\Course Technology\\CIS Programming\\ASP .NET Programming\\Data Files\\Chapter.09\\Chapter\\SkywardAviation.mdf; Integrated Security=True; User Instance=True");
                   }
        try
        {
            dbConnection.Open();
            SqlCommand sqlCommand = new SqlCommand(
                "INSERT INTO FrequentFlyers (last, first,"
                + " phone, email, password, cardType,"
                + " expireMonth, expireYear, cardnumber,"
                + " cardholder, address, city, state, zip,"
                + " travelerType, homeAirport, class, seat,"
                + " meal) VALUES("
                + "'" + lastName.Text + "',"
                + "'" + firstName.Text + "',"
                + "'" + telephone.Text + "',"
                + "'" + email.Text + "',"
                + "'" + hiddenPassword.Value + "',"
                + "'" + creditcard.Text + "',"
                + "'" + expireMonth.Text + "',"
                + "'" + expireYear.Text + "',"
                + "'" + cardnumber.Text + "',"
                + "'" + cardholder.Text + "',"
                + "'" + address.Text + "',"
                + "'" + city.Text + "',"
                + "'" + state.Text + "',"
                + "'" + zip.Text + "',"
                + "'" + travelerType.Text + "',"
                + "'" + homeAirport.Text + "',"
                + "'" + serviceClass.Text + "',"
                + "'" + seatPreference.Text + "',"
                + "'" + mealRequest.Text + "',)",
                dbConnection);
            sqlCommand.ExecuteNonQuery();
            sqlCommand = new SqlCommand(
                "SELECT IDENT_CURRENT('FrequentFlyers')",
                dbConnection);
            SqlDataReader lastID=
                SqlCommand.ExecuteReader();
            if(lastID.read())
                successString.Text +=
                "<h3>Enrollment Sucessful</h3>
                <p>Your frequent flyer number is " + lastID.GetValue(0) + ".</p>";
        }
       catch (SqlException exception)
       {
            successString.Text += "<p>Error code "
                + exception.Number
                + ": " + exception.Message + "</p>";
}
dbConnection.Close();
       
}
}


This is homework!
homework-image.pdf
0
Comment
Question by:assaultkitty
  • 2
5 Comments
 
LVL 37

Expert Comment

by:Neil Russell
ID: 37817265
Change

                "<h3>Enrollment Sucessful</h3>
                <p>Your frequent flyer number is " + lastID.GetValue(0) + ".</p>";

to be ONE LINE

                "<h3>Enrollment Sucessful</h3><p>Your frequent flyer number is " + lastID.GetValue(0) + ".</p>";
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 37817268
Same problem as before. This should be on one line or you have to use plus signs to concatenate.

successString.Text +=
                "<h3>Enrollment Sucessful</h3>"
                + "<p>Your frequent flyer number is " + lastID.GetValue(0) + ".</p>";
0
 

Author Comment

by:assaultkitty
ID: 37817312
Thank you.  I do know why the book has it like that.  Thanks.
0
 

Author Comment

by:assaultkitty
ID: 37840446
I did not make a mistake.  The  + sign was the deciding factor.  I was having problems getting the newline error to go away.  In addition, I tried them both and tommyboy's worked.  As, you see I have worked with tommyboy on several projects and he has helped me and he has been very patient with me as I working through my learning.  Please tell neilsr, I am sorry and I look forward to working with him on my final two projects as software engineering student.  I will be a graduate on April 25.  Wish me luck!  

Recommendation for change:
1. Leave points as is.

http:ID: 37817268

I received 100% on this particular project thanks to tommyboy.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now