gbe*_*927 1 c# sql linq asp.net submitchanges
我有一个表单,可以向数据库添加记录.主键是自动递增的.我想将网页重定向到显示刚刚输入的信息的页面.
例如,如果1019是生成的下一个数字,它将重定向到http://localhost/details.aspx?softwareID = 1019.
这是将其提交给DB的代码.
software software = new software
{
EQCN = txtEQCN.Text,
title = txtTitle.Text,
version = txtVersion.Text,
license = txtLicense.Text,
expirationDate = txtExpirationDate.Text
};
db.softwares.InsertOnSubmit(software);
db.SubmitChanges();
Run Code Online (Sandbox Code Playgroud)
Linq-To-Sql支持开箱即用.在调用SubmitChanges与您的PK对应的您的propety的值之后应该具有新值.特别是,IsDbGenerated相应[Column]属性的属性应该为true(尽管如果你通过设计器运行它,它就已经存在).
| 归档时间: |
|
| 查看次数: |
89 次 |
| 最近记录: |