use "select count(*) from yourtable", for example:using System;
using System.Data;
using System.Data.SqlClient;SqlConnection conn= new SqlConnection("Put_Your_Connection_String_Here");
SqlCommand cmd = new SqlCommand("SELECT Count (*) FROM YourTable", conn);
conn.Open();
int nCount = (Int32)cmd.ExecuteScalar();
conn.Close();
if (nCount > 0)
Console.WriteLine("有记录");
else
Console.WriteLine("没有记录");
using System.Data;
using System.Data.SqlClient;SqlConnection conn= new SqlConnection("Put_Your_Connection_String_Here");
SqlCommand cmd = new SqlCommand("SELECT Count (*) FROM YourTable", conn);
conn.Open();
int nCount = (Int32)cmd.ExecuteScalar();
conn.Close();
if (nCount > 0)
Console.WriteLine("有记录");
else
Console.WriteLine("没有记录");
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货