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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:16:24+00:00 2026-05-13T18:16:24+00:00

Hey all I’m trying to do the following insert query SqlDataSource userQuizDataSource = new

  • 0

Hey all I’m trying to do the following insert query

SqlDataSource userQuizDataSource = new SqlDataSource();
userQuizDataSource.ConnectionString = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=quizApp;Integrated Security=True";
userQuizDataSource.InsertCommand = "INSERT INTO [UserQuiz] ([DateTimeComplete], [Score], [UserName]) VALUES (@DateTimeComplete, @Score, @UserName)";

userQuizDataSource.InsertParameters.Add("DateTimeComplete", DateTime.Now.ToString());
userQuizDataSource.InsertParameters.Add("Score", score.ToString());
userQuizDataSource.InsertParameters.Add("UserName", User.Identity.Name);

int rowsAffected = userQuizDataSource.Insert();

Buti keep getting the following error:

The conversion of a nvarchar data type
to a smalldatetime data type resulted
in an out-of-range value.
The statement has been terminated.

Can anyone help me out?

  • 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-13T18:16:24+00:00Added an answer on May 13, 2026 at 6:16 pm

    What does your statement DateTime.Now.ToString() return??

    What language and regional settings is your SQL Server expecting??

    Do you have a mismatch there??? Maybe your .NET returns a MM/dd/yyyy format, while SQL Server expects dd/MM/yyyy (or vice-versa).

    Try this code in your SQL Server:

    DECLARE @test TABLE (smalldate SMALLDATETIME)
    INSERT INTO @test VALUES ('02/21/2010 22:00:32') --
    SELECT * FROM @test
    

    Replace my string there with what output you got from .NET’s DateTime.Now.ToString() – does this work? Does SQL Server give you a better error message?

    Next, try to use the ISO-8601 format for dates (YYYYMMDD) – this works for ALL regional and language settings in SQL Server – does this work??

    DECLARE @test TABLE (smalldate SMALLDATETIME)
    INSERT INTO @test VALUES ('20100221 22:00:32') --
    SELECT * FROM @test
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, i am trying to learn how to insert a comment within some
Hey all i am new at C# and i am trying to call the
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey all. I'm trying to set a value on a hidden form element based
Hey all, i am trying to get my bottom bar to center on the
Hey all i am trying to delete a key from the registery but i
Hey all. I've been been trying to figure this out for a while now.
Hey all, this is my query string here: SELECT SUM(Total) as Total, AdministratorCode, SUM(WOD.Quantity)
Hey all! I am trying to post a file over Http using Java 1.4.2.
Hey all i have an XML file that i am trying to loop though.

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.