当前位置:编程学习 > C#/ASP.NET >>

求这段代码的意思


  public int ExecSQL(global::System.Object tableAdapter,
                                            global::System.String strSQL)
        {
            try
            {
                Type tpAdapter = tableAdapter.GetType();

                tpAdapter.InvokeMember("Connection",
                    BindingFlags.SetProperty |
                    BindingFlags.Public |
                    BindingFlags.NonPublic |
                    BindingFlags.Instance,
                    null, tableAdapter, new global::System.Object[] { this._connection });

                global::System.Data.SqlClient.SqlCommand[] sCommCollection =
                    (global::System.Data.SqlClient.SqlCommand[])tpAdapter.InvokeMember("CommandCollection",
                    BindingFlags.GetProperty |
                    BindingFlags.Public |
                    BindingFlags.NonPublic |
                    BindingFlags.Instance,
                    null, tableAdapter, null);



                global::System.Data.SqlClient.SqlCommand sc = sCommCollection[0].Clone();
                sc.CommandText = strSQL;

                sc.Connection.Open();

                return sc.ExecuteNonQuery();


            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
--------------------编程问答-------------------- 执行更新或者删除的SQL语句 --------------------编程问答-------------------- 有点不对吧,返回值是int型的,而sc.ExecuteNonQuery()并不返回任何值啊……
--------------------编程问答-------------------- sc.ExecuteNonQuery() 方法的返回值是个int,为操作影响的行数 --------------------编程问答-------------------- Exec SQL
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,