简体   繁体   English

如何在Visual Studio 2017中从C#代码制作SQL Server 2017本地数据库?

[英]How to make a SQL Server 2017 local database from C# code in Visual Studio 2017?

I am trying to write a console game in C#, however, I am running into trouble trying to generate my database for information on the characters, and stage. 我试图用C#编写一个控制台游戏,但是,尝试生成有关角色和舞台信息的数据库时遇到了麻烦。

My questions are: how do I 我的问题是:我该怎么办

  1. Create a database file from C# code? 从C#代码创建数据库文件?
  2. Connect to that database after it is been created? 创建数据库后连接到该数据库?
  3. And how to add tables to that database from C# code? 以及如何从C#代码向该数据库添加表?

I was thinking that I could use fileinfo and filestream classes to make the .mdf file, but I would rather be safe by asking you guys. 我当时想我可以使用fileinfo和filestream类来制作.mdf文件,但是我想通过问你们是安全的。

.net for c# has a library for this, the using statement has to be activated manually though. .net for c#有一个用于此的库,但是using语句必须手动激活。 If you click project in visual studio and click add reference and go to the extras. 如果您单击Visual Studio中的项目,然后单击添加引用,然后转到其他。 Mysql.data should have everything you need. Mysql.data应该具有您需要的一切。 And you can connect to the data base by just making a string out of the command. 您只需在命令中输入一个字符串即可连接到数据库。 But connect to the database first. 但是先连接到数据库。

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

相关问题 如何使用SQL Server数据库在Visual Studio 2017中创建安装文件 - How to create setup file in Visual Studio 2017 with SQL Server database 从C#代码调用PS脚本(Visual Studio 2017) - Invoking PS script from C# code (Visual studio 2017) 如何在Visual Studio 2017中使用C#建立SQL连接? - how to build a SQL connection using C# in Visual Studio 2017? 如何使用Visual Studio 2017中编译的C#应用​​程序连接到SQL Server 2008? - How to connect to SQL Server 2008 with C# application compiled in Visual Studio 2017? C#:如何从数据库的最后一行获取数据? 我在Visual Studio 2017中使用 - C#: How to get data from the last row in database? I'm using in visual studio 2017 如何将本地数据库文件添加到 Visual Studio Mac 2017 - How to add local database file to Visual Studio Mac 2017 C#-Visual Studio 2017-获取预定义方法的实际代码 - C# - Visual Studio 2017 - Get actual code of predefined methods Visual Studio 2017 C# - 如何将本地 .txt 列表的内容导入 ComboBox 的选项? - Visual Studio 2017 C# - How do you import the contents of a local .txt list into a ComboBox's options? 从Visual Studio 2017社区建立到Linux虚拟机上运行的mysql的ac#连接 - make a c# connection to mysql running on linux virtual box from visual studio 2017 community 导航助手 C# Visual Studio 2017 - Navigation Helper C# Visual Studio 2017
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM