【发布时间】:2017-09-13 07:29:43
【问题描述】:
**public static void göster()
{
SqlConnection connection =GetConnection.GetConnectionObject();
//TODO parametreleri command.parameters yoluyla alsın
SqlCommand command = new SqlCommand();
command.CommandText= "select * from windowsserv";
command.Connection = connection;
if (connection.State != ConnectionState.Open)
connection.Open();
Console.WriteLine("Connection opened");
SqlDataReader rdr = command.ExecuteReader();
while(rdr.Read())
{
------------------> Console.WriteLine(rdr[0].ToString()+"--"+rdr[1].ToString());
}
if (connection.State != ConnectionState.Closed)
connection.Close();
Console.WriteLine("Connection Closed.");
Console.ReadLine();
}
大家好,这是我的代码,还有更多我没有显示的,我将数据记录到 sql server。此代码块(用箭头指向)显示所有 sql server 数据,我只想在控制台中查看最后一个数据(记录到 sql server)。但是我找不到任何答案。请帮忙。**
【问题讨论】:
-
这是一个很奇怪的问题。从您的问题中无法判断“最后数据”的定义应该是什么。
标签: c# .net sql-server ado