コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add2(Log_Info model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Log_Info(");
            strSql.Append("[LogClassID], [LogTypeId], [mapid], [mapid2], [LogMemo], [IsStar], [AddTime], [userid], [orgid], [cityid], [isdel], [isadmin], [DBSource], [AddFromMethod], [adddate]");
            strSql.Append(") values (");
            strSql.Append("@LogClassID, @LogTypeId,@mapid,@mapid2,@LogMemo,@IsStar,@AddTime,@userid,@orgid,@cityid,@isdel,@isadmin,@DBSource,@AddFromMethod,@adddate");
            strSql.Append(") ");
            //strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LogClassID",    SqlDbType.Int,         4),
                new SqlParameter("@LogTypeId",     SqlDbType.Int,         4),
                new SqlParameter("@mapid",         SqlDbType.Int,         4),
                new SqlParameter("@mapid2",        SqlDbType.Int,         4),
                new SqlParameter("@LogMemo",       SqlDbType.VarChar,   200),
                new SqlParameter("@IsStar",        SqlDbType.Bit,         2),
                new SqlParameter("@AddTime",       SqlDbType.DateTime),
                new SqlParameter("@userid",        SqlDbType.Int,         4),
                new SqlParameter("@orgid",         SqlDbType.Int,         4),
                new SqlParameter("@cityid",        SqlDbType.Int,         4),
                new SqlParameter("@isdel",         SqlDbType.Int,         4),
                new SqlParameter("@isadmin",       SqlDbType.Int,         4),
                new SqlParameter("@DBSource",      SqlDbType.Int,         4),
                new SqlParameter("@AddFromMethod", SqlDbType.VarChar,   200),
                new SqlParameter("@adddate",       SqlDbType.DateTime),
            };

            parameters[0].Value  = model.LogClassID;
            parameters[1].Value  = model.LogTypeId;
            parameters[2].Value  = model.mapid;
            parameters[3].Value  = model.mapid2;
            parameters[4].Value  = model.LogMemo;
            parameters[5].Value  = model.IsStar;
            parameters[6].Value  = model.AddTime;
            parameters[7].Value  = model.userid;
            parameters[8].Value  = model.orgid;
            parameters[9].Value  = model.cityid;
            parameters[10].Value = model.isdel;
            parameters[11].Value = model.isadmin;
            parameters[12].Value = model.DBSource;
            parameters[13].Value = model.AddFromMethod;
            parameters[14].Value = model.adddate;


            object obj = SQLDBHelper.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Log_Info loginfo)
        {
            //StringBuilder strSql = new StringBuilder();
            //strSql.Append("insert into Log_Info(");
            //strSql.Append("[LogClassID], [LogTypeId], [mapid], [mapid2], [LogMemo], [IsStar], [AddTime], [userid], [orgid], [cityid], [isdel], [isadmin], [DBSource], [AddFromMethod], [adddate]");
            //strSql.Append(") values ");
            //strSql.Append(") values (");
            //strSql.Append("1, 0,884444,884444,\'{0}\',0,\'{1}\',0,0,0,0,0,0,\'{2}\',\'{3}\'");
            //strSql.Append(") ");

            //for (int a = 0; a < 100; a++)
            //{
            //    StringBuilder sql_list = new StringBuilder();
            //    for (int i = 0; i < 1000; i++)
            //    {
            //        sql_list.Append(string.Format(strSql.ToString(), loginfo.LogMemo, loginfo.AddTime,
            //            loginfo.AddFromMethod, loginfo.adddate));
            //        sql_list.Append(";");
            //    }

            //    object obj = SQLDBHelper.GetSingle(sql_list.ToString(), null);
            //}
            string val = "(1, 0,884444,884444,\'{0}\',0,\'{1}\',0,0,0,0,0,0,\'{2}\',\'{3}\'),";

            for (int a = 0; a < 100; a++)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into Log_Info(");
                strSql.Append("[LogClassID], [LogTypeId], [mapid], [mapid2], [LogMemo], [IsStar], [AddTime], [userid], [orgid], [cityid], [isdel], [isadmin], [DBSource], [AddFromMethod], [adddate]");
                strSql.Append(") values ");

                StringBuilder sql_list = new StringBuilder();
                for (int i = 0; i < 1000; i++)
                {
                    strSql.Append(string.Format(val.ToString(), loginfo.LogMemo, loginfo.AddTime, loginfo.AddFromMethod, loginfo.adddate));
                }

                object obj = SQLDBHelper.GetSingle(strSql.ToString().TrimEnd((',')), null);
            }

            return(0);
        }