suni dotnet

suni dotnet

  • NA
  • 7
  • 0

string not recognised as valid datetime!!! VERY VERY URGENT

Jan 9 2009 12:20 PM
Hi everyone,
iam trying to convert a gridview cell value (input by user) into datetime.
i tried almost all methods to convert but into vain. working on this from past 3 weeks. plz help...
my code:
string connectionstring = WebConfigurationManager.ConnectionStrings["RoyalHotelManagement"].ConnectionString;
            SqlConnection con = new SqlConnection(connectionstring);
            SqlCommand cmd = new SqlCommand("InsertSuite", con);
            cmd.CommandType = CommandType.StoredProcedure;
            string filleddate = GridView2.Rows[e.RowIndex].Cells[2].Text;
            string freedate = GridView2.Rows[e.RowIndex].Cells[3].Text;
            IFormatProvider theCultureInfo = new System.Globalization.CultureInfo("en-US", true);
            DateTime filleddate1 = DateTime.ParseExact(filleddate, "mm/dd/yyyy HH:mm:ss", theCultureInfo);
          DateTime freedate1 = DateTime.ParseExact(freedate, "mm/dd/yyyy HH:mm:ss", theCultureInfo);
            cmd.Parameters.AddWithValue("@filleddate", filleddate1);
            cmd.Parameters.AddWithValue("@freedate", freedate1);
            cmd.Parameters.AddWithValue("@nameofcustomer", GridView2.Rows[e.RowIndex].Cells[6].Text);
            try
            {
                con.Open();
               
                SqlDataReader reader = cmd.ExecuteReader();


            }
            finally
            {
                con.Close();
            }

my storedprocedure:
ALTER PROCEDURE InsertSuite
   
    @filleddate datetime,
    @freedate datetime,
    @nameofcustomer varchar(50)
   
AS
BEGIN

    SET NOCOUNT ON
    Insert into PresidentialSuite(DateWhenFilled,DateWhenFree,NameOfCustomer)
    values (@filleddate,@freedate,@nameofcustomer);
END

i tried even with update.... no use

thanks in advance..

   









































































































Answers (7)