C# and SQL SELECT
<p>Currently I am working on a project regarding C# and SQL and I have a problem regarding the SELECT function and I cannot find any solutions on-line. </p>

<p>The scenario is regard searching query from C# through SQL server and display the results in a Data Grid View at C#.</p>

<p>I'm using Visual Studio 2008 and SQL Server Studio 2008.</p>

<p>Before starting the project I just did a quick Windows form from Visual studio and just did a datagridview, 2 text boxes and a Search Button. </p>

<p>At SQL Server I have a a database with a table DVD and I want to search, from this Windows form with the DVD ID and Name.</p>

<p>I started with the DVD ID and implemented this code :</p>

<pre><code>private void btnView_Click(object sender, EventArgs e)
{
   SqlConnection c = new SqlConnection(@"Data Source=GILBERTB-PC\SQLEXPRESS;Initial Catalog=DVDandGameBooking;Integrated Security=True"); 

   DataTable t = new DataTable();

   string sqlString = "SELECT * From DVD where Id ='" + txtID.Text+ "'";

   SqlDataAdapter dt = new SqlDataAdapter(sqlString, c);        
   dt.Fill(t);

   dtgv1.DataSource = t;
}
</code></pre>

<p>and it worked :)</p>

<p>Then I changed the code to  </p>

<pre><code>string sqlString = "SELECT * From DVD where Name ='" + txtName.Text+ "'";
</code></pre>

<p>so that I can search with Name of the DVD <strong>but</strong> when I started the program and searched with the Name it just showed a blank database </p>

<p>Also is there any way that I can change the code so that I can either search with the ID or with the Name ?</p>

<p>Thanks for your help and time</p>
