我正在 AsyncUpload 集合中执行一个简单的 foreach 循环到 Byte[] 并尝试将其插入数据库。
foreach (UploadedFile file in AsyncUpload1.UploadedFiles)
{
string[] splitFileExt = file.FileName.Split('.');
List<string> CommandArgs = new List<string>();
CommandArgs.Add("IID|" + Request.QueryString["InstructorID"]);
CommandArgs.Add("FName|" + file.FileName);
CommandArgs.Add("FTitle|" + file.FileName);
CommandArgs.Add("FType|" + file.ContentType);
CommandArgs.Add("FExtension|" + splitFileExt[1]);
CommandArgs.Add("FSize|" + file.ContentLength.ToString());
byte[] b = StaticControlCreationClass.ReadToEnd(file.InputStream);
MySQLProcessing.MySQLProcessor.MySQL_UploadFile(b, "fileupload", CommandArgs, mysqlCon);
}
public static void MySQL_UploadFile(byte[] value, string MYSQLCommand, List<string> CommandArgs, MySqlConnection con)
{
MySqlCommand cmd = new MySqlCommand(MYSQLCommand, con);
cmd.Parameters.AddWithValue("FContent", value);
foreach (string args in CommandArgs)
{
string[] splitArgs = args.Split('|');
cmd.Parameters.AddWithValue(splitArgs[0], splitArgs[1].Trim());
}
cmd.ExecuteNonQuery();
}
然后这里是存储过程
如果存在文件上传,则删除程序;
创建过程文件上传`(
IID 整数,
TValue varchar(250),
FName varchar(250),
FType varchar(15),
FSize varchar(45),
FContent longblob,
FExtension varchar(10))
开始
SET @IID = IID;
SET @TValue = TValue;
SET @FName = FName;
SET @FType = FType;
设置@FSize = FSize;
SET @FExtension = FExtension;
SET @FContent = FContent;
插入到 tblfiles(rID,
标题,
文件名,
文件类型,
文件大小,
文件_内容,
文件扩展名)
值(@IID,
@T值,
@F名称,
@F类型,
@FS大小,
@F内容,
@FExtension);
结尾
我不断收到You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fileupload' at line 1@ cmd.ExecuteNonQuery();
任何帮助表示赞赏。