What is creating a newline in my constant?

I'm getting a "newline in constant" error in my C# after adding the TIME_FORMAT function(from MySQL), into an SQL string that I'm building and I'm not sure why or how to fix it. I tried to escape the '%' character that precedes the 'T' for the 2nd parameter of the function, but it didn't solve the problem and gave me a different error as a matter of fact. Why does it think that by adding "TIME_FORMAT("00:00:00", "%T")  to my string, that I'm adding a new line in my constant? Please help.


my MySQL string in C#
sql = String.Format(@"SELECT 
	AthleteUid, AthleteFullName, SEC_TO_TIME((SUM(TIMESTAMPDIFF(MINUTE, TimeIn, TimeOut))) * 60) AS WeekTotal, RequiredHours, SportTeamName AS SportTeam 
FROM 
	utathleteinfo uai 
    	INNER JOIN 
    utinout uio on uai.AthleteUid = uio.StudentID 
    	INNER JOIN 
    utsportteam ust ON ust.utSportTeamUid = uai.SportUid 
WHERE 
	uio.TimeOut IS NOT NULL 
    AND uio.TimeIn >= '2018-01-29 00:00:00' 
    AND uio.TimeOut <= '2018-02-02 23:59:59' 
GROUP BY 
	uai.AthleteUid, AthleteFullName, WeekTotal, RequiredHours, SportTeamName, SemesterTime, Coach 
ORDER BY 
 	AthleteFullName)
UNION
(SELECT 
	AthleteUid, AthleteFullName, TIME_FORMAT("00:00:00", "%T") AS WeekTotal, RequiredHours, SportTeamName AS SportTeam 
FROM 
	utathleteinfo uai 
    	INNER JOIN 
    utinout uio on uai.AthleteUid = uio.StudentID 
    	INNER JOIN 
    utsportteam ust ON ust.utSportTeamUid = uai.SportUid 
WHERE 
	WeekTotal = '0:00'
GROUP BY 
	uai.AthleteUid, AthleteFullName, WeekTotal, RequiredHours, SportTeamName, SemesterTime, Coach
ORDER BY 
 	AthleteFullName) ORDER BY AthleteFullName");

Open in new window


the error:

" Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1010: Newline in constant

Source Error:


Line 202:                              sql = sql + String.Format(@" UNION
Line 203:                                    (SELECT
Line 204:                                          AthleteUid, AthleteFullName, TIME_FORMAT("00:00:00", "%T") AS WeekTotal, RequiredHours, SportTeamName AS SportTeam
Line 205:                                    FROM
Line 206:                                          utathleteinfo uai "
LVL 1
Michael SterlingWeb Applications DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ares KurkluSoftware EngineerCommented:
Hi ,

I believe you need to use double " in this case such as  TIME_FORMAT(""00:00:00"", ""%T"")
2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michael SterlingWeb Applications DeveloperAuthor Commented:
That worked. Thanks.
0
NorieAnalyst Assistant Commented:
Have you tried using single quotes instead of double quotes inside the SQL statement?
...
SELECT 
	AthleteUid, AthleteFullName, TIME_FORMAT('00:00:00', '%T') AS WeekTotal, RequiredHours, SportTeamName AS SportTeam 
FROM 
	utathleteinfo uai 
    	INNER JOIN 
    utinout uio on uai.AthleteUid = uio.StudentID 
    	INNER JOIN 
    utsportteam ust ON ust.utSportTeamUid = uai.SportUid 
...

Open in new window

1
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Michael SterlingWeb Applications DeveloperAuthor Commented:
@Norie: That was my first attempt and it didn't work. The double quotes solved it.
0
NorieAnalyst Assistant Commented:
Strange, you use single quotes in other parts of the SQL statement and when I tested it (lightly) it seemed to work fine.:)
1
Michael SterlingWeb Applications DeveloperAuthor Commented:
Yeah, the whole thing threw me off. I didn't understand why it didn't work in the first place.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.