title: check db record exists using .ADO.net connection
body: <p>I am just wondering how can I check if a database exists in C# using ADO.net without EF. please advise .thanks so much</p>
  <p>Below is my Controller</p>
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public IActionResult Create(string Name, string ID)
  {
        string myConnectionString;
        DataTable dt = new DataTable();
        //connect DB
        myConnectionString = &quot;Data Source=xxxxxx&quot;
        //Validation   
      if (ModelState.IsValid)
      {
          using (SqlConnection sqlConn = new
          SqlConnection(myConnectionString))
          {
              string sql = &quot;insert into [DB] (ID,Name) Values('&quot; + ID + &quot;','&quot; + Name + &quot;)&quot;;
              using (SqlCommand sqlCmd = new SqlCommand(sql, sqlConn))
              {
                  sqlCmd.CommandType = CommandType.Text;
                  sqlConn.Open();
                  using (SqlDataAdapter sqlAdapter = new
                      SqlDataAdapter(sqlCmd))
                  {
                      sqlAdapter.Fill(dt);
                  }
              }
          }
      }
  }
  </code></pre>