Exemplo n.º 1
0
            /// <summary>
            /// 单一SQL语句获取数据表
            /// </summary>
            /// <param name="sql"></param>
            /// <param name="para"></param>
            /// <returns></returns>
            public DataTable GetDTBySingleSql(string sql, ParaCollection para)
            {
                //定义一个DataTable实例
                DataTable result = new DataTable();

                //定义SQL语句集
                SqlDataCollection sqlData = new SqlDataCollection();

                sqlData.Add(new SqlData(sql, para));
                try
                {
                    if (service.Excute(result, sqlData, DBOperationFashion.Select))
                    {
                        int row = result.Rows.Count;
                        return(result);
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception)
                {
                    return(null);
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// 单一SQL语句数据库写操作
            /// </summary>
            /// <param name="sql"></param>
            /// <param name="para"></param>
            /// <returns></returns>
            public bool WriteDBBySingleSql(string sql, ParaCollection para)
            {
                //定义SQL语句集
                SqlDataCollection sqlData = new SqlDataCollection();

                sqlData.Add(new SqlData(sql, para));

                try
                {
                    return(service.Excute(new DataTable(), sqlData, DBOperationFashion.Other));
                }
                catch (Exception)
                {
                    return(false);
                }
            }
Exemplo n.º 3
0
            /// <summary>
            /// 多个SQL语句数据库写操作
            /// </summary>
            /// <param name="sqlDatas"></param>
            /// <returns></returns>
            public bool WriteDBByMultiSql(List <SqlData> sqlDatas)
            {
                //定义SQL语句集
                SqlDataCollection sqlDataCes = new SqlDataCollection();

                foreach (SqlData sd in sqlDatas)
                {
                    sqlDataCes.Add(sd);
                }
                try
                {
                    return(service.Excute(new DataTable(), sqlDataCes, DBOperationFashion.Other));
                }
                catch (Exception)
                {
                    return(false);
                }
            }