受影响的行数 [英] Number of rows affected

查看:90
本文介绍了受影响的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我想知道如何知道在asp.net.net mvc程序中UPDATE / DELETE / INSERT Oracle查询中受影响的行数< br $> b $ b

我的尝试:



ExuteNonQuery ===>返回-1

我也使用了sql%rowcount但是没有返回任何内容

Hello,

I want to know how to know the number of rows affected in UPDATE/DELETE/INSERT Oracle query in asp.net.net mvc program

What I have tried:

ExuteNonQuery ===> return -1
I used also sql%rowcount but doesn't return anything

推荐答案

我不知道你是如何准备查询的?你在使用sqlcommand吗?你没有给出你的代码,我无法正确帮助你。但请看看这个链接 [ ^ ],它会对你有所帮助。







I am not sure how you are preparing the query? are you using sqlcommand ?. you did not given your code, I can't help you correctly. But look into this link[^], it will help you.



using (SqlConnection con = new SqlConnection(constring))
{
    using (SqlCommand cmd = new SqlCommand("UPDATE Persons SET City = @City WHERE Name = @Name", con))
    {
        cmd.CommandType = CommandType.Text;
        cmd.Parameters.AddWithValue("@Name", name);
        cmd.Parameters.AddWithValue("@City", city);
        con.Open();
        int rowsAffected = cmd.ExecuteNonQuery();
        con.Close();
    }
}





--RA



--RA


这篇关于受影响的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆