开发者

C# SQLCommandBuilder Help

I have project where i want to use the sqlcommandbuilder.

My only problem is that i can not find a decent example of how to use it, or just simply does not understand why it is used like that.

I am building my application based on 3-tier architecture.

Lets say for instance i want to generate a update statement. where does the commandbuilder get the value from to update into the database. i am currently using the normal sqlcommand and manually creates every sql statement. but ten开发者_如何学Pythonds to be a hassle due to multiple database tables, and it gets confusing.

This is for my final project for my software engineering subject. Please need help.


I second the remarks in the comments above... a good ORM is definitely worth looking at.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommandbuilder.aspx

Note: the example that MS have there is fairly good actually.

They pretty much say everything I'd have said.

  1. load up the select command
  2. The commandBuilder will generate Update, Insert, and Delete statements
  3. it only auto generates SQL for a single table
  4. if you need anything more than that, you'll need to generate the SQL statements by hand, and then load them into the CommandBuilder.

  5. the command builder works reasonably well with a DataTable, which in turn can be bound to a DataView in ASP.Net.

By contrast, a good ORM (provided your database is supported) such as nhibernate, can generate multi-table updates + give you a degree of database vendor independence.

A good reason to learn it is so that you can answer any questions that come up in MS certification exams, or perhaps when using databases unsupported by your ORM of choice... or maybe your just want to get something up and running quickly.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜