在两个表中插入数据 [英] insert data in two tables

查看:60
本文介绍了在两个表中插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何通过C#在sql Server 2005中插入数据,我有两个表,一个表名是"category_type"主表",第二个表名是子类别"外部表"
category_type属性是(PK)type_id,category_name .........子类别属性是(PK)sub_id,(FK)type_id,item_name .....我想在前端用户中隐藏type_id不要在type_id列的前端"how"

how i insert data in sql server 2005 through c# i have two table one table name is "category_type""primary table" the second table name is "sub category""foreign table"
the category_type attributes are (PK)type_id,category_name......... the sub category attributes are (PK)sub_id,(FK)type_id,item_name..... i want to hide type_id in the front end user do not entered type_id in front end "how"

推荐答案

中输入type_id,在sql server中将其"Identity Specification"设置为true.从您的用户中获取除type_id以外的其他列的值.

尝试以下sql字符串-
插入category_type(category_name)值(您的类别名称"))"
for the type_id column, set its "Identity Specification" to true in sql server. Take values for other columns except type_id from your user.

try the following sql string-
"insert into category_type(category_name) values(''your category name'')"


这篇关于在两个表中插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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