string sql = "insert into Table_UploadFile(FileTitle,FileContent, FileType)values (@FileTitle,@FileContent,@FileType)
;Select @@IDENTITY";
SqlParameter[] param = new SqlParameter[3]{
new SqlParameter("@FileTitle", fileTitle),
new SqlParameter("@FileContent", fileContent),
new SqlParameter("@FileType",fileType)
};
//调用数据库操作
//int res = sqlhelper.ExecuteNonQuery(sql, CommandType.Text, param);
int res = Convert.ToInt32(sqlhelper. ExecuteScalar(sql, CommandType.Text, param).ToString());
if (res != 0)
{
return res;//直接返回就是操作后的FileID
}
else
{
return 0;
}
SqlParameter[] param = new SqlParameter[3]{
new SqlParameter("@FileTitle", fileTitle),
new SqlParameter("@FileContent", fileContent),
new SqlParameter("@FileType",fileType)
};
//调用数据库操作
//int res = sqlhelper.ExecuteNonQuery(sql, CommandType.Text, param);
int res = Convert.ToInt32(sqlhelper. ExecuteScalar(sql, CommandType.Text, param).ToString());
if (res != 0)
{
return res;//直接返回就是操作后的FileID
}
else
{
return 0;
}