c# - 如何在sql表的新多列表中插入特定列
问题描述
我怎样才能做到这一点?当我在 sql 表中有两列以上时,是否可以只在两列上插入请有人帮我实现这一点。
我在下面尝试了这段代码:
SqlConnection Conn = new SqlConnection(shoolmanangmentconn);
Conn.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO tbl_TestingThatSubjects(INDO, LANGUAGE,BIOLOGY,
GEOGRAPHY) VALUES (@IDNO,@LANGUAGE,@BIOLOGY,@GEOGRAPHY)", Conn);
cmd.Parameters.AddWithValue("@IDNO", txtids.Text);
cmd.Parameters.AddWithValue("@LANGUAGE", txtlanguage.Text);
cmd.ExecuteNonQuery();
我试图只插入 LANGUAGE 列而不插入其他列请有人教我如何做正确的事情。(我正在使用 wpf c#)
解决方案
The columns either need to Allow Nulls or have a Default Value:
This is how you can extend database schema's without breaking existing codebases.
ps look into the using
statement for unmanaged objects, such as the SqlConnection and SqlCommand objects.
推荐阅读
- databricks - databricks POST 调用以执行带有参数的笔记本
- html - css动画工具反转
- c - C - 程序未检测到空格
- javascript - 可以访问数组的特定位置,但不能访问该数组内的特定对象
- amazon-web-services - 更改 kinesis 的 aws lambda 消费者批量大小是否会导致数据丢失或重复
- c# - 为什么实体框架第二次尝试存储我的外键?
- c# - 在具有导航属性的表单中使用 TryUpdateModelAsync 时出错
- svelte - 如何使用 Svelte 对内部变化的元素进行动画处理?
- python-3.x - 使用 numpy 沿 4D 数组的第一个轴平均 n 个元素
- javascript - 为什么我的JS在第一首完成后没有播放另一首歌曲?