string sqlc="insert into docfujian (filen,filedata,flag) values (@Filename,@Filedata,@Flag) SELECT @@IDENTITY as id";
SqlCommand myCommand = new SqlCommand(sqlc, myConnection);myCommand.Parameters.Add(new SqlParameter("@Filename", SqlDbType.VarChar));
myCommand.Parameters["@Filename"].Value =Path.GetFileName(UpFile.FileName.ToString());myCommand.Parameters.Add(new SqlParameter("@Flag", SqlDbType.VarChar));
myCommand.Parameters["@Flag"].Value ="no";myCommand.Parameters.Add(new SqlParameter("@Filedata", SqlDbType.Image));
myCommand.Parameters["@Filedata"].Value =FileByteArray; myCommand.Connection.Open();
int Id = Convert.ToInt32(myCommand.ExecuteScalar());//id就是你需要的
myCommand.Connection.Close();
SqlCommand myCommand = new SqlCommand(sqlc, myConnection);myCommand.Parameters.Add(new SqlParameter("@Filename", SqlDbType.VarChar));
myCommand.Parameters["@Filename"].Value =Path.GetFileName(UpFile.FileName.ToString());myCommand.Parameters.Add(new SqlParameter("@Flag", SqlDbType.VarChar));
myCommand.Parameters["@Flag"].Value ="no";myCommand.Parameters.Add(new SqlParameter("@Filedata", SqlDbType.Image));
myCommand.Parameters["@Filedata"].Value =FileByteArray; myCommand.Connection.Open();
int Id = Convert.ToInt32(myCommand.ExecuteScalar());//id就是你需要的
myCommand.Connection.Close();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货