SqlCommand or SqlDataAdapter?

后端 未结 6 1027
鱼传尺愫
鱼传尺愫 2020-12-10 05:21

I\'m creating something like a small cashier application that keeps record for the clients, employees, services, sales, and appointments. I\'m using windows forms, and withi

6条回答
  •  春和景丽
    2020-12-10 05:35

    This is highly depend upon type of operation you want.

    Following is my suggetion.

    1. If you want to read data faster go for SQLDataReader but that comes as cost of operation you need to take during read after that also. Open Connection Read Data Close Connection. If you forgot to close than it will hit performance.

    2. Go for SQLDataAdapter

      • If you want to read faster and use benefit of Disconnected Arch. of ADO.net
      • This will automatically close/open connection.
      • Also it will also allow you to automatically handle update in DataSet back to DataBase. ( SqlCommandBuilder)
    3. Use SQLCommand ( This will also comes when you read SQLDataReader for read data) and for insert and update.

      • This will give you better performance for insert and update.

    If you are using .NET Frame 3.5 sp1 or later i would suggest Linq to SQL or Entity Framework would also solve your purpose.

    Thanks.

提交回复
热议问题