且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将数据添加到我的SQL数据库

更新时间:2023-02-07 11:16:34

很可能你找不到符合你需要的确切代码。相反,您需要了解并学习制作程序的每个步骤。所有编程都不是关于复制。



正如所说的将问题分解成更小的部分。这是SQL Server:

1.绘制表单,添加必要的元素并给它们正确的名称。不要使用 Textbox1 但名称如 LastName

2.创建代码连接到数据库并执行 INSERT 语句。例如,您可以通过正确执行数据库操作 [ ^ ]

3.要返回新添加的键值使用 OUTPUT子句 [ ^ ]



虽然创建程序的每个部分,花时间,探索和观察不同的可能性如何做,稍作修改以了解它们如何影响并始终利用调试器来理解行为:使用调试器浏览代码 [ ^ ]
Most likely you won't find exact code that suits your needs. Instead you need to understand and learn each step for making the program. After all programming isn't about copying.

As said break the problem into smaller pieces. Taken this is SQL Server:
1. Draw the form, add necessary elements to it and give them proper names. Don't use Textbox1 but names like LastName.
2. Create the code for connecting into database and executing the INSERT statement. You can for example read through Properly executing database operations[^]
3. To return the newly added key value use the OUTPUT clause[^]

While creating each piece of the program, take your time, explore and observe the different possibilities how to do things, make slight modifications to see how they affect and always utilize the debugger to understand the behaviour: Navigating through Code with the Debugger[^]


参见 sql教程 - Google搜索 [ ^ ]。