?
Solved

Airline 4

Posted on 2012-04-06
5
Medium Priority
?
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

800 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