用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - c#代码库

二进制上传

2015-06-17 作者: 莫名其妙举报

[c#]代码库

                byte[] image = ImgToSteam(PageClass.ImgUrl);
                string FileUPload = Common.FileInsert("files", "FILENAME,FILEFORMAT,CREATETIME,CREATEUSER", "'" + PageClass.ImgFileName + "','" + PageClass.ImgFileType + "','" + DateTime.Now + "','" + AdminUser.Username + "'", image);
                File.Delete(PageClass.ImgUrl);
                fileid = Convert.ToInt32(FileUPload);



     public static string FileInsert(string TableName, string column, string columnvalue, Byte[] FileByteArray)
        {

            DataSet ds;
            SqlParameter[] paras = {
                new SqlParameter("TableName",TableName),
                new SqlParameter("ColumnName",column),
                new SqlParameter("ColumnValue",columnvalue),
                   };
            ds = dbHelper.ExecuteDataset(ConfigurationManager.AppSettings["ConnectionString"], CommandType.StoredProcedure, "File_Insert", paras);
            if (ds.Tables[0].Rows[0][0].ToString() == null)
            { }
            else
            {
                string Sql = "Update " + TableName + " set IMGFILE=@UpFile where FileID='" + ds.Tables[0].Rows[0][0].ToString() + "'";
                SqlConnection myCn = new SqlConnection(ConnectionString);
                SqlCommand myCmd = new SqlCommand(Sql, myCn);
                myCmd.Parameters.Add("@UpFile", SqlDbType.Image, FileByteArray.Length);
                myCmd.Parameters["@UpFile"].Value = FileByteArray;
                myCn.Open();
                myCmd.ExecuteNonQuery();
                myCn.Close();
            }
            return ds.Tables[0].Rows[0][0].ToString();

        }
        public static string ImgUpdata(string TableName, Byte[] FileByteArray, string FILENAME, string FileID)
        {
            string Sql = "Update " + TableName + " set IMGFILE=@UpFile ,FILENAME=@FILENAME where FileID='" + FileID + "'";
            SqlConnection myCn = new SqlConnection(ConnectionString);
            SqlCommand myCmd = new SqlCommand(Sql, myCn);
            myCmd.Parameters.Add("@UpFile", SqlDbType.Image, FileByteArray.Length);
            myCmd.Parameters.Add("@FILENAME", SqlDbType.VarChar);
            myCmd.Parameters["@FILENAME"].Value = FILENAME;
            myCmd.Parameters["@UpFile"].Value = FileByteArray;
            myCn.Open();
            myCmd.ExecuteNonQuery();
            myCn.Close();
            return FileID;
        }
        public static string IconUpdata(string TableName, Byte[] FileByteArray, string FileID)
        {
            string Sql = "Update " + TableName + " set CerLogo=@UpFile  where ID='" + FileID + "'";
            SqlConnection myCn = new SqlConnection(ConnectionString);
            SqlCommand myCmd = new SqlCommand(Sql, myCn);
            myCmd.Parameters.Add("@UpFile", SqlDbType.Image, FileByteArray.Length);
            myCmd.Parameters["@UpFile"].Value = FileByteArray;
            myCn.Open();
            myCmd.ExecuteNonQuery();
            myCn.Close();
            return FileID;
        }
        public static string FileUpdata(string TableName, Byte[] FileByteArray, string FileID)
        {
            string Sql = "Update " + TableName + " set PDF=@UpFile  where ID='" + FileID + "'";
            SqlConnection myCn = new SqlConnection(ConnectionString);
            SqlCommand myCmd = new SqlCommand(Sql, myCn);
            myCmd.Parameters.Add("@UpFile", SqlDbType.Image, FileByteArray.Length);
            myCmd.Parameters["@UpFile"].Value = FileByteArray;
            myCn.Open();
            myCmd.ExecuteNonQuery();
            myCn.Close();
            return FileID;
        }


网友评论    (发表评论)

共7 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...