开发者

DataSet - easy way to create new table?

I use Visual Studio 2010 with C# to write a database application. Until now, I used the guided dialog to add a DataSet to my current project. In the project explorer tree on the right side, a node "mydatabase.xsd" is created.

On the left side, I have the server explorer. From there, I can drag existing tables onto the DataSet-designer to create the references (to my understanding, VS auto-generates code in the background). The references (or TableAdapters etc. respectively) can be used in t开发者_开发知识库he source code, in the form of mydatabase.mytable

This is very convenient as I don't have to deal with the details of the connection settings, and it keeps SQL code out of my eyesight.

If, however, I want to create a new table in the existing database, VS does not seem to offer any assistance. I looked at the MSDN-specification. They tell you how to create the table object and the column definitions and how to link it to the DataSet, but not how to actually save it into the database. In all the examples I found on Google, you'd have to explicitly, manually, define a ConnectionString, SQL commands or similar. With all the VS GUI advancements, this seems rather convoluted to me. Is there an easy way to accomplish it?


Open Server Explorer, click Add Data Connection and supply connection information to your database, click OK. Right Click on Tables folder and click Add Table. Add Fields, etc to your new datatable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜