troubleshooting Question

What am i doing wrong specify a Date field as a parameter

Avatar of Olukayode Oluwole
Olukayode OluwoleFlag for Canada asked on
PostgreSQLC#* Parameters
14 Comments3 Solutions42 ViewsLast Modified:
I have the script below that should take screen values , put them through a processor
and then write to a database .

I have a c# program writing to a postgresql database through a stored procedure. This is a  testdabase  just to master how to write different field types to the database.. I use Dapper with my application.. Below is the script used

DatabaseWriteUpdateDeleteProccesor processor65 = new DatabaseWriteUpdateDeleteProccesor();
var outValue = processor65.TestDataRecordNumber(testcharValue.Text, Convert.ToDateTime(testdateValue.Text), Convert.ToBoolean(testboolValue.Checked), Convert.ToDecimal(testamountValue.Text), Convert.ToInt32(idValue.Text), "public.spdatatypestable_updateinsert");

[]public string TestDataRecordNumber(string para01, DateTime para02, bool para03, decimal para04, int para05, string theStoredProcedure)
            string outValue = null;
            outValue = GetTestDataRecordNumber(para01, para02, para03,para04,para05, theStoredProcedure);
            return outValue;

        private string GetTestDataRecordNumber(string para01x, DateTime para02x, bool para03x, decimal para04x, int para05x,  string storedprocedurex)
            string outValue = "xxx";
            var parameter65 = new { testcharx = para01x, testdatex = para02x, testboolx = para03x, testamountx = para04x, idx = para05x };
            NewDataAccess.WriteData(storedprocedurex, parameter65);
            return outValue;

The script  generating the error is shown below

                using (var conn = new NpgsqlConnection(LoginDetails.staticconnectionstring))
                    int newRecordId = conn.QuerySingleOrDefault<int>(sql, p, commandType: CommandType.StoredProcedure);
                    LoginDetails.staticmasterrecordid = newRecordId;

I have 5 field type (string, date, bool , decimal and integer)

Below is the debbugged screen showing the parameters fields well setup

and the input screen for the 5 field types  shown below

The script worked when i did not involve a date field.. It wrote the data to the database.

Somehow once i introduce the date field the error crops up

If any body has a script that write  a Date field to a postgre database using the method above

i will appreciate it



Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 3 Answers and 14 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 3 Answers and 14 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004