i am new to postgresql, and now we have to change our code in C# for using db as postgresql from sql, following code is working fine with sql
public PL.Type GetDetails(int ID)
{
PL.Type obj = null;
SqlParameter[] parameters = new SqlParameter[]
{
new SqlParameter("@Action", "GetDetails"),
new SqlParameter("@ID", ID)
};
//Lets get the list of all Type in a datataable
using (DataTable table = DL.SqlDbHelper.ExecuteParamerizedSelectCommand("sp_Type", CommandType.StoredProcedure, parameters))
{
//check if any record exist or not
if (table.Rows.Count == 1)
{
DataRow row = table.Rows[0];
//Lets go ahead and create the list of Type
obj = new PL.Type();
//Now lets populate the Type details into the list of Types
obj.ID = Convert.ToInt32(row["ID"]);
obj.Name = row["Name"].ToString();
}
}
return obj;
}
but when we are trying the same to use postgresql db its not working, changed code for postgresql is as under
public PL.Type GetDetails(int ID)
{
PL.Type obj = null;
NpgsqlParameter[] parameters = new NpgsqlParameter[]
{
new NpgsqlParameter("@Action", "GetDetails"),
new NpgsqlParameter("@ID", ID)
};
//Lets get the list of all Type in a datataable
using (DataTable table = DL.PostgreSQLDbHelper.ExecuteParamerizedSelectCommand("sp_Type", CommandType.StoredProcedure, parameters))
{
//check if any record exist or not
if (table.Rows.Count == 1)
{
DataRow row = table.Rows[0];
//Lets go ahead and create the list of Type
obj = new PL.Type();
//Now lets populate the Type details into the list of Types
obj.ID = Convert.ToInt32(row["ID"]);
obj.Name = row["Name"].ToString();
}
}
return obj;
}