برگرداندن مقدار یک دستور select در C#‎

ساخت وبلاگ

این مثال دم دستی هست:


public int A()
{
string stmt = "SELECT COUNT(*) FROM dbo.tablename";
int count = 0;

using(SqlConnection thisConnection = new SqlConnection("Data Source=DATASOURCE"))
{
using(SqlCommand cmdCount = new SqlCommand(stmt, thisConnection))
{
thisConnection.Open();
count = (int)cmdCount.ExecuteScalar();
}
}
retu count;
}

برنامه نویس...
ما را در سایت برنامه نویس دنبال می کنید

برچسب : نویسنده : محمد رضا جوادیان programers بازدید : 158 تاريخ : جمعه 2 تير 1396 ساعت: 18:29