如何创建一个简单的Windows窗体来访问SQL Server数据库?窗体、创建一个、简单、数据库

2023-09-03 07:12:09 作者:遣心

我相信这是一个非常初级的问题,如果我使用了错误的论坛问,请告知。

I believe this is a very novice question, and if I'm using the wrong forum to ask, please advise.

我有一个基本的了解建库与MS SQL服务器和编程与C ++和C#。我试图教我更多的通过设置了我自己的数据库与MS SQL Server的防爆preSS 2008 R2,并通过在C#中前preSS 2010年创建此时Windows窗体访问它,我只是想继续它释放或Ex preSS开发工具(不一定是微软虽然)。

I have a basic understanding of databasing with MS SQL Server, and programming with C++ and C#. I'm trying to teach myself more by setting up my own database with MS SQL Server Express 2008 R2 and accessing it via Windows forms created in C# Express 2010. At this point, I just want to keep it to free or Express dev tools (not necessarily Microsoft though).

不管怎样,我创建使用提供此处指令的数据库,我设置了适当的数据类型为每列(在设置至少没有错误)。

Anyway, I created a database using the instructions provided here and I set the data types appropriately for each column (no errors in setup at least).

现在我设计在C#中前preSS图形用户界面,但那种我已经打了一堵墙,只要数据库连接。

Now I'm designing the GUI in C# Express but I've kind of hit a wall as far as the database connection.

有没有访问使用C#防爆preSS我在本地创建数据库中的一个简单的方法?任何人都可以提出一个指导具有所有这阐明了吗?

Is there a simple way to access the database I created locally using C# Express? Can anyone suggest a guide that has all this spelled out already?

我是一个自我学习,所以我期待着自学如何使用这些应用程序,但任何指针开始我关在正确的方向将是极大的AP preciated。

I am a self-learner so I look forward to teaching myself how to use these applications, but any pointers to start me off in the right direction would be greatly appreciated.

推荐答案

我会采取看看这个教程开始:

I'd start by taking a look at this tutorial:

http://msdn.microsoft.com/en-us/library/ ms178371.aspx

其基本思路是建立一个连接字符串将定义了一些事情包括:在您的数据库服务器是什么,数据库名称,以及如何连接到它

The basic ideas is to create a connection string that will define a number of things, including: where your db server is, what the database name is, and how you are connecting to it.

一旦你有你的连接字符串定义,你可能会使用的的SqlConnection ,的SqlCommand 和 SqlDataReader的类与数据库的所有交互。如果你点击链接,这三个类别,并期待在文档中,你会看到他们有pretty的很好的例子。

Once you have your connection string defined you will probably use the SqlConnection, SqlCommand and SqlDataReader classes for all interactions with the database. If you click on the links for those three classes and look at the documentation you will see they have pretty good examples.