postgresql - .Net Core 3.1 和 Postgresql 插入和更新查询未执行,但选择查询运行成功
问题描述
大家好,当我请求 postgresql 运行任何插入数据并在 refcursor 中选择数据的函数时,我正在使用没有实体框架的 Postgresql 和 .Net Core Api 3.1。
在此函数中,选择查询运行良好,但数据未插入数据库表中。
相同的功能在 Asp .Net Web Forms 中正常工作,但在 Asp .Net Core 中不能正常工作。
我是 postgresql 的新手
public string Save_Siteinpection_update(SiteInspection model)
{
string result = ResponseStatus.FAILED;
try
{
var conn = SqlHelper.NpSqlConnection();
conn.Open();
DataSet ds = new DataSet();
var tran = conn.BeginTransaction();
var command1 = new NpgsqlCommand("mob_sp_siteinspection_update3", conn);
command1.Parameters.AddWithValue("para_document_sno", Convert.ToInt64(model.docsrno));
command1.Parameters.AddWithValue("para_dig_code", Convert.ToInt32(model.dig_code));
command1.Parameters.AddWithValue("para_srocode", Convert.ToInt32(model.srocode));
command1.Parameters.AddWithValue("para_site_visited", model.site_visited);
command1.Parameters.AddWithValue("para_visit_satisfy", model.visit_satisfy);
command1.Parameters.AddWithValue("para_contact_person", model.contact_person);
command1.Parameters.AddWithValue("para_longitude_prop", model.longitude_prop);
command1.Parameters.AddWithValue("para_latitude_prop", model.latitude_prop);
command1.Parameters.AddWithValue("para_adrees_prop", model.adrees_prop);
command1.Parameters.AddWithValue("para_city_prop", model.city_prop);
command1.Parameters.AddWithValue("para_zip", model.zip);
command1.Parameters.AddWithValue("para_country_prop", model.country_prop);
command1.Parameters.AddWithValue("para_state_prop", model.state_prop);
command1.Parameters.AddWithValue("para_img1", model.img1);
command1.Parameters.AddWithValue("para_img2", model.img2);
command1.Parameters.AddWithValue("para_img3", model.img3);
command1.Parameters.AddWithValue("para_img4", model.img4);
command1.Parameters.AddWithValue("para_remark", model.remark);
command1.CommandType = CommandType.StoredProcedure;
NpgsqlDataAdapter da = new NpgsqlDataAdapter(command1);
da.Fill(ds);
string np_no = ds.Tables[0].Rows[0]["mob_sp_siteinspection_update3"].ToString();
command1.CommandText = "fetch all in \"" + np_no + "\"";
command1.CommandType = CommandType.Text;
NpgsqlDataReader sdr = command1.ExecuteReader();
while (sdr.Read())
{
result = Convert.ToString(sdr[0].ToString());
}
sdr.Close();
conn.Close();
}
catch (Exception ex)
{
}
return result;
}
解决方案
推荐阅读
- ios - UIBarButtonItems 不起作用
- database - redshift 领导节点使用了 100% 的磁盘
- python - 将两个列表分配为彼此相等
- python - 当使用 Python 类作为程序配置结构(包括继承的类属性)时,保存/恢复的好方法是什么?
- sdk - 如何获取 apache-beam .tar.gz 文件?
- oauth-2.0 - 如何进行快速书 Api 调用和绕过登录
- opengl-es - 多重采样渲染缓冲区的目的是什么
- java - xtend 是否支持多个构造函数?
- ios - 是否存在不会将应用程序启动到后台的静默远程通知?
- java - 如何使用 JTS 或 NTS 找到曲线角点?