請教一下,如何用C#從sql server資料庫中選取某一行的資料(比如第二行或第三行)?

  • 作者:由 匿名使用者 發表于 攝影
  • 2022-09-10

請教一下,如何用C#從sql server資料庫中選取某一行的資料(比如第二行或第三行)?伴你走天涯2016.12.26 回答

select top 2 * from table order by id desc 這是選擇第二行

其他的都類似,如果選擇多行中的某行,只能透過select巢狀查詢了。。

請教一下,如何用C#從sql server資料庫中選取某一行的資料(比如第二行或第三行)?匿名使用者2016.12.26 回答

you need to add row_number() over (order by your column) as column appending to your query, then you can control

請教一下,如何用C#從sql server資料庫中選取某一行的資料(比如第二行或第三行)?2016.12.26 回答

先說說你用c#語句建立資料庫吧,我貼個例子給你你就懂了。 string myexecutequery=“create database test”; //建立test資料庫 sqlconnection mysqlconnection = new sqlconnection(“server=mysqlserver;user id=sa;password=sa;trusted_connection=yes;”); sqlcommand mycommand = new sqlcommand(myexecutequery, mysqlconnection); mycommand。connection。open(); mycommand。executenonquery(); mysqlconnection。close(); 下面再說說你在winform裡建立視覺化資料表,在。net 2。0平臺裡有很多相應的控制元件可以使用,以達到你說的視覺化操作資料庫程式。 注意在程式頭部新增: using system。data。sql; //引用

Top