0

Sir/Madam,

I am going to perform Oracle bulk insert but invalid bind parameter Papameters : System.dateTime warns here.

The field of Created Date is timestamp(0) which 22-MAR-13 08.13.27.000000000 PM is only accpeted format.

but when I trying to convert from string to DateTime as follows:

3/22/2013 8:00:00PM

using the following method:

 item.CreatedDate = Convert.ToDateTime("19-MAR-13 08.13.27 PM");

// BELOW IS ORACLE BULK INSERT

        using (OracleConnection myConnection = new OracleConnection(myConnectionString))
        {
            myConnection.Open();
            using (var copy = new OracleBulkCopy(myConnection))
            {
                copy.DestinationTableName = "T_BQ";
                copy.BulkCopyTimeout = 10;
                copy.BatchSize = 1000;
                var query = from item in list select item;
                var dt = new System.Data.DataTable();
                dt = ConvertToDataTable(query);
                copy.WriteToServer(dt);
                copy.Dispose();
                copy.Close();
            }
            myConnection.Dispose();
            myConnection.Close();
        }
1
  • have you checked my answer ? Commented Mar 25, 2013 at 7:14

3 Answers 3

3

You can use DateTime.TryParseExact for custom datetime format as:

 string strDateStarted = "19-MAR-13 08.13.27 AM";
 DateTime datDateStarted;
 DateTime.TryParseExact(strDateStarted, new string[] { "dd-MMM-yy hh.mm.ss tt" }, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out datDateStarted);
 Console.WriteLine(datDateStarted);
Sign up to request clarification or add additional context in comments.

Comments

3

You should using : for time separator instead .

Try this:

item.CreatedDate = Convert.ToDateTime("19-MAR-13 08:13:27 PM");

2 Comments

Invalid parameter binding Parameter name: System.DateTime happens
@RajuGujarati: post more code in your question especially the code that caused the error.
2

try this,

dateVariable.ToString("MM/dd/yyyy hh:mm:sstt");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.