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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:46:19+00:00 2026-06-04T02:46:19+00:00

My code gives the above error. I have tried to change it based on

  • 0

My code gives the above error.

I have tried to change it based on the link below:

String was not recognized as a valid DateTime “ format dd/MM/yyyy”

but it still does not work.

Would be grateful if somebody can point me in the right direction.

My code is below:

foreach (GridViewRow row in GridView1.Rows)

        {

       // int RowIndex = 0;
       // GridViewRow row = (GridViewRow)GridView1.Rows[RowIndex];

            Int32 intresortID = Convert.ToInt32(Request.QueryString["TypeID"]);
            Label dtm = row.FindControl("Label1") as Label;
            Label strRoomType = row.FindControl("Label2") as Label;
            Label strDescription = row.FindControl("Label3") as Label;
            TextBox Qty = row.FindControl("intQtyTextBox") as TextBox;
            TextBox Price = row.FindControl("curPriceTextBox") as TextBox;
            Label intWSCode = row.FindControl("intWSCodeLabel") as Label;

            string connStr = ConfigurationManager.ConnectionStrings["bestandConnectionString"].ConnectionString;
            using (SqlConnection Con = new SqlConnection(connStr))
            {
                Con.Open();
                SqlCommand cmd = new SqlCommand("Update tblAvail set intqty=@intQty, curprice=@curprice where intresortid=@intresortid and dtm=@dtm and strroomtype=@strroomtype", Con);

cmd.Parameters.AddWithValue(“@dtm”,
DateTime.ParseExact(dtm.Text.Trim(), “dd / MM / yyyy”,null));
Line giving the error

                cmd.Parameters.AddWithValue("@strroomtype", strRoomType.Text.Trim());
                cmd.Parameters.AddWithValue("@intQty", Qty.Text.Trim());
                cmd.Parameters.AddWithValue("@curPrice", Price.Text.Trim());
                cmd.Parameters.AddWithValue("@intResortID", intresortID);

                cmd.ExecuteNonQuery();
                GridView1.EditIndex = -1;
                DataBind();

            }

In design Mode:

  <ItemTemplate>
        <asp:Label ID="Label1" runat="server" 
                        Text='<%# Eval("Dtm", "{0:dd/MM/yyyy}") %>'></asp:Label>
  </ItemTemplate>

When debugging dtm value comes as:

{Text = “18/05/2012”}

  • 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-04T02:46:20+00:00Added an answer on June 4, 2026 at 2:46 am

    Try

    DateTime.ParseExact(dtm.Text.Trim(), "dd/M/yyyy", System.Globalization.CultureInfo.InvariantCulture)
    

    four y instead of 3 and InvariantCulture

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

Sidebar

Related Questions

Ok, so I have a formset that is valid. But gives me a error
I am getting object reference error while putting string.format in stringbuilder. I have below
Why this below code gives segmentation fault? int main() { char *t = Working
This very simple code gives me tons of errors: #include <iostream> #include <string> int
In C++ the following code gives a compiler error: void destruct1 (int * item)
This piece of code gives a syntax error at the colon of elif process.loop(i,
Executing the below code gives me the following exception on the last line: InvalidOperationException:
The following C++ code gives an error while compiling: #include<iostream> using namespace std; class
I am not sure why this code (gives stackoverflow at runtime) compiles: import java.io.*;
I have a txt file which has data in the below format: int string

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.