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;
}[/code]
The script generating the error is shown below
[]try
{
using (var conn = new NpgsqlConnection(LoginDetails.staticconnectionstring))
{
int newRecordId = conn.QuerySingleOrDefault<int>(sql, p, commandType: CommandType.StoredProcedure);
LoginDetails.staticmasterrecordid = newRecordId;
}
}[/code]
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
Thanks
Olukay
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.