Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7077993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:29:31+00:00 2026-05-28T06:29:31+00:00

To prep my question defensively, I’ve utilized Google, Bing and StackOv prior to posting

  • 0

To prep my question defensively, I’ve utilized Google, Bing and StackOv prior to posting :-). Also, I’m new to MVC3 and still grappling with the syntactical intricacies of the framework.

I have an error in my SQL statement in the code block below which is bugging me quite a bit. The syntax appears correct. I simplified the SQL statement with a Select * From.. and it returns data just fine.

Also, if there is a better way to do this (without using an EF object), definitely open to suggestions. I really like the flexibility and control of seeing the SQL Statement – either that, or just used to it as form of habit :-).

Thanks in advance!!

@using System.Data.SqlClient;
@using System.Configuration;

@{
    Layout = null;
}
@{
    SqlConnection cn = null;
    cn = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlConn"].ToString());
    cn.Open();
   SqlCommand cmd = new SqlCommand((@"SELECT DISTINCT" +
                                    "tblSBT.sname," +
                                    "tblSBDetails.sid," + 
                                    "tblSBDetails.assignedtrack," + 
                                    "tblSBDetails.maxtrack," + 
                                    "tblSBDetails.currentvals," + 
                                    "tblSBDetails.maxvals," + 
                                    "tblSBDetails.lastupdated" +
                                    "FROM" +         
                                        "tblSBT (NOLOCK)" +
                                    "LEFT OUTER JOIN" +
                                        "tblSBDetails (NOLOCK)" +
                                    "ON" +
                                        "tblSBT.sid = tblSBDetails.sid" +                      
                                    "WHERE" +
                                    "tblSBDetails.lastupdated > DateADD(n, -5, GETDATE())"+
                                    "ORDER BY" +
                                    "tblSBT.sname" +), cn);

    var myreader = cmd.ExecuteReader();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:29:31+00:00Added an answer on May 28, 2026 at 6:29 am

    If you’re using the @ symbol, you don’t need to concatenate your strings like how you are doing it. It’s also not the most efficient way of writing that piece of code when you’re joining strings like that.

    SqlConnection cn = null;
    cn = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlConn"].ToString());
    cn.Open();
    SqlCommand cmd = new SqlCommand((@"SELECT DISTINCT
            tblSBT.sname,
            tblSBDetails.sid,
            tblSBT.sname,
            tblSBDetails.sid, 
            tblSBDetails.assignedtrack,
            tblSBDetails.maxtrack,
            tblSBDetails.currentvals,
            tblSBDetails.maxvals,  
            tblSBDetails.lastupdated
            FROM    tblSBT (NOLOCK)
                        LEFT OUTER JOIN tblSBDetails (NOLOCK)
                            ON .sid = tblSBDetails.sid
            WHERE   tblSBDetails.lastupdated > DateADD(n, -5, GETDATE())
            ORDER BY    tblSBT.sname"), cn);
    
    var myreader = cmd.ExecuteReader();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a number of Python scripts that help prep a staging area
My Question is similar to This SO question , but with the main difference
First of all, i'm a Graphic designer so please ignore if this programming question
I am new into PHPUnit and just digging through the manual I cannot find
I'm prototyping some text processing to prep research data for coding, and I've got
I have the following code: $data = array(); // prep array $data['aardvark'] = true;
Quick design question. ClassA has a method called DoSomething(args) In DoSomething(), before it can
Sorry, this is probably a really stupid question, but is it safe to run
Question 1 : Can I just use $userid = mysql_real_escape_string($_GET['user_id']); Or I need to
I was recently reading a book as prep for an interview and came across

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.