DataTable result = null; try { using (con) { using (SqlCommand cmd = con.CreateCommand()) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "CheckSite"; cmd.Parameters.Add(new SqlParameter("@site", site)); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { result = new DataTable(); da.Fill(result); if (result.Rows.Count>0) { return 1; } } } } } catch (Exception ex) { //Pokemon exception handling } return 0;
ALTER PROCEDURE dbo.CheckSite @site nvarchar(150) AS select sitename from Saved where sitename = @site RETURN
if (result.Rows.Count>0)
SET NOCOUNT OFF;
..... .... ... using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { DataSet result = new DataSet(); dataset.Tables.Add("aaa"); da.Fill(dataset, "aaa"); if (result.Tables[0].Rows.Count>0) { return 1; } } ........ .......
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)