如何在上传到数据库后获取上传文件的最新文件ID? [英] how to get the latest File ID of uploaded File after uploading it into database ?

查看:401
本文介绍了如何在上传到数据库后获取上传文件的最新文件ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图在asp.net项目中上传带有文件上传控件的docx文件,然后将其保存在数据库中,我的数据库包含三个相关的表:

File_Table:

FileID是(主键和自动关联)

,FileName,Data



Text_Table:

FileID,文字



Image_table:

FileID,imgID,img



并且文件上传成功并成功存储,但我的外键和主键(FileID)有问题;将Text_Table和Image_table中的FileID存储为Null !!!

我该如何解决这个问题?我可以通过会话方法解决它!!?以及如果是的话!?



任何人都可以帮助我!???



谢谢,

Hi,
I was tried to upload a docx file with file upload control in asp.net project ,and then save it in database , my database contain three related tables :
File_Table :
FileID which is (primary key & auto correlated)
,FileName,Data

Text_Table :
FileID,Text

Image_table:
FileID,imgID,img

and the files were uploaded successfully and stored Successfully, but I have a problem with foreign key and primary key (FileID) ; which the FileID in Text_Table and in Image_table was stored as a Null !!!
how can i solve this issue ? and can i solve it by session method !!? and how if yes!?

can anyone help me please!???

thanks,

推荐答案

如果您在数据库中使用标识列...当我们要保存新记录时,它会增加它的值...通过考虑您可以获得最新添加记录详细信息/您想要的身份密钥
if you use the identity column in your data base... it increments it''s value when we are going to save a new record...by considering that identity key you may get the latest add record details/ what you want


我想将text_table中的FileID存储为file_table中的相同值

什么时候同时存储相同的文件信息,但我不能这样做..

你可以帮帮我吗?
i want to store the FileID in the text_table as the same value in the file_table
when is store the same file information at the same time , but i can''t do this ..
can you help me?


这篇关于如何在上传到数据库后获取上传文件的最新文件ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆