将aspx页中的值保存到数据库 [英] saving a value in aspx page to database
本文介绍了将aspx页中的值保存到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在aspx页面上有一个问题,我要在表1中保存前8个值.保存值后,获取表1的值会自动生成ID,然后将其他4个字段保存到另一个table2中.最后一个table1的ID和将剩余值保存到表3中,我该怎么做
I have a problem in my aspx page there r 12 fields I want to save first 8 value in table 1 .after saving value getting table 1 auto generating id and save other 4 field to another table2 .and at last table1 id and rest value saving to table 3 how can i do it
推荐答案
这是非常基本的ADO.NET编码
This is very basic ADO.NET coding
using(SqlCommand cmd1 = new SqlCommand("proc name", connection))
{
cmd1.Paramaters.AddWithValue(...);
// repeat as necesasry
cmd1.ExecuteNonQuery();
int id = (int)cmd1.Paramters["output param name"].Value;
}
重复其他插入.
Repeat for other inserts.
这篇关于将aspx页中的值保存到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文