简体   繁体   English

我已经使用Visual Studio为C#程序创建了一个数据库表。 怎么办?

[英]I've created a database table using Visual Studio for my C# program. Now what?

I'm very new to C#, so please forgive me if I've overlooked something here. 我是C#的新手,所以如果我忽略了这里的内容,请原谅我。 I've created a database using Visual Studio (add new item > service-based database) called LoadForecast.mdf. 我已经使用Visual Studio(添加新项>基于服务的数据库)创建了一个名为LoadForecast.mdf的数据库。 I then created a table called ForecastsDB and added some fields. 然后,我创建了一个名为ForecastsDB的表,并添加了一些字段。 My main question is this: I've created a console application with the intention of writing some data to the newly created database. 我的主要问题是:我创建了一个控制台应用程序,旨在将一些数据写入到新创建的数据库中。 I've added LoadForecast.mdf as a data source for my program, but is there anything else I should do? 我已经将LoadForecast.mdf添加为程序的数据源,但是还有什么我应该做的吗? I saw an example where the next step was adding a "data diagram", but this was for a visual application, not a console application. 我看到了一个示例,其中下一步是添加“数据图”,但这是针对可视应用程序而不是控制台应用程序的。 Do I still need to diagram the database for my console app? 我还需要为控制台应用程序绘制数据库图吗? I just want to be able to write new records out to my database table and wasn't sure if there were any other things I needed to do for the VS environment to be "aware" of my database. 我只是希望能够将新记录写到数据库表中,并且不确定是否需要做其他事情才能使VS环境“了解”我的数据库。 Thanks for any advise! 感谢您的任何建议!

Well, it depends on what data access technology you want to use. 好吧,这取决于您要使用哪种数据访问技术。 You can use straight SqlClient, you can use untyped data sets, you can use strongly typed data sets, you can use LINQ to SQL, you can use Entity Framework. 您可以使用直接的SqlClient,可以使用无类型的数据集,可以使用强类型的数据集,可以使用LINQ to SQL,可以使用实体框架。

If you're not sure, then probably the most fun would be LINQ to SQL, so I recommend you follow a tutorial first and then come back to your app. 如果不确定,那么最有趣的可能就是LINQ to SQL,所以我建议您先阅读教程,然后再返回您的应用程序。 Eg. 例如。 ScottGu's LINQ to SQL (Part 4 - Updating our Database) , or MSDN's How to: Insert Rows Into the Database . ScottGu的LINQ to SQL(第4部分-更新我们的数据库) ,或MSDN的How to:在数据库中插入行

There are also video guides, like VS2008 Training Kit: Using LINQ with Relational Data or MSDN Webcast: Using LINQ with Relational Data (Level 100) . 也有视频指南,例如VS2008培训工具包:将LINQ与关系数据一起使用MSDN网络广播:将LINQ与关系数据一起使用(级别100)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我写了一个C#程序。 我可以把它放在我的WP7手机上吗? - I've written a C# program. Can I put it on my WP7 phone? C# - 无法访问我刚刚使用另一个 Visual Studio 2015 程序创建的简单的 1 表 mdf 数据库中的数据 - C# - Can't access data from a simple, 1-table mdf database that I have just created with another Visual Studio 2015 program 我尝试使用Visual Studio C#调试我的程序时出错 - error when i try to debug my program, using Visual Studio C# 我已经失去了Visual Studio C#2008的设计视图 - I've lost the design view of Visual Studio C# 2008 如何使用Visual Studio在C#应用程序中发布Access数据库? - How do I publish an Access database with my C# application using Visual Studio? 在Linux中使用Visual Studio C#程序 - Using Visual Studio C# program in Linux 我需要使用visual studio(c#语言)创建一个sql server数据库表。 但表的名称必须是用户的输入 - I need to create a sql server database table using visual studio(c# language) . But the name of the table has to be an input from the user 如何将在 Visual Studio C# 中创建的数据库迁移到 SQL 服务器? - How to migrate a DataBase created in Visual Studio C# to a SQL Server? 使用Visual Studio C#在Management Studio中编辑数据库 - Edit database in management studio using visual studio c# Visual Studio C#使用计时器按住程序1小时 - Visual Studio C# using timer to hold down the program for 1 hour
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM