在数据库中插入新行 [英] Inserting a new row into database

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

问题描述

private void button1_Click(object sender, EventArgs e)
        {
            this.tableTableAdapter.Insert("some text in 1st collumn", "2", "3", "4", "5");
            this.tableTableAdapter.Update(this.webDataSet.table);
            
        }



我正在使用DataGridView.需要手动添加记录(而不是通过在DataGridView中编辑)并更新表.
请帮忙.



I''m using DataGridView. Need to add records manually(not by editing in DataGridView) and update table.
Please, help.

推荐答案

请参见,每当您向数据库中插入内容时,都需要一条insert语句.

如果要从tableTableAdapter内部调用插入语句,则可以,否则,需要SqlCommand对象来创建命令. :)
See, whenever you are inserting something into database, you need an insert statement.

If you are invoking an insert statement from inside tableTableAdapter then it is fine, otherwise you need SqlCommand object to create your command. :)


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

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