SQL/C# - Best method for executing a query

前端 未结 5 548
谎友^
谎友^ 2020-12-02 01:49

I need to execute a sql query from within a c# class. I have thought of 2 options

  1. Starting a process of sqlcmd.
  2. Using a SqlCommand object.
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 02:06

    I think SqlCommand is a clear winner because you don't need to wire up a different process. You can close the database connection as soon as you're done with it.

    And then you can also distribute the application to machines that don't have sqlcmd available.

提交回复
热议问题