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; |
} |
初级程序员
by: 云代码会员 发表于:2015-06-19 15:32:22 顶(0) | 踩(0) 回复
不错
回复评论