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 8035573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:21:03+00:00 2026-06-05T02:21:03+00:00

really a simple question , I have two Variables one_hour_ago and current_time, I need

  • 0

really a simple question , I have two Variables “one_hour_ago” and “current_time”, I need to pass these two variables in my sql command like :

string commandString = "SELECT * from myTable where time between one_hour_ago and current_time";

here is what I have but I get syntax error

string commandString = "SELECT * from myTable where TS between ' and /" + one_hour_ago + "'" + current_time + "/"; 

Thanks

  • 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-06-05T02:21:04+00:00Added an answer on June 5, 2026 at 2:21 am
    string sqlString = "SELECT * FROM myTable WHERE time BETWEEN  @before AND @current_time"; 
    SqlCommand oCmd = new SqlCommand(sqlString , connString);
    oCmd.Parameters.AddWithValue("@before", date_before);
    oCmd.Parameters.AddWithValue("@current_time", currentTime);
    

    where date_before and currentTime are the parameters you pass to the method.

    this should take care of the sql injection stuff

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A really simple shell script question. I have a file with something like this:
Really simple question time: I have two divs. <div id=1> <p>hello</p> </div> <div id=2>
I have what is probably a really simple, studid question but I can't find
This sounds like a really simple question, but I am new to PHP. If
I need your help. I have made a really clean and simple example to
I have two questions... Here is a really simple example script which causes an
Really simple question: From within GWT I want to forward the user away from
Really simple question. I forgot how to deal with this specific script. With a
Really simple question here but bugging me for long enough to ask. Code looks
This is a really simple question, but I can't seem to find the answer.

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.