title: Trying to get a data from sql database: what to enter into textbox
body: <p>I have text-box named <code>txtitemcode</code>,  when I type the item-code into text box I want to to display the corresponding data into grid-view or text boxes. </p>
  
  <p>But it's not firing the code, I don't know where I am wrong, I search in the Google and keep change the codes , finally I got one still its not working.  I am pasting my code here..</p>
  
    
  
  <pre class="lang-vb prettyprint-override"><code>Public Sub SelectItem(ByVal ItemCode As String)
          Try
              sql.OpenDbConnection()
              Dim strSQL As String = "SELECT ItemCode as 'Item Code',ItemName as 'Item Name' FROM tblItemMaster where ItemCode='ItemCode'"
              'SqlConn.Close()
              Dim da As New SqlDataAdapter(strSQL, sql.SqlConn)
              Dim ds As New DataSet
              da.Fill(ds, "tblItemMaster")
              dgvPurchaseOrder.DataSource = ds.Tables("tblItemMaster")
              sql.SqlConn.Close()
          Catch ex As SqlException
              MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
          Catch ex As Exception
              MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
          End Try
      End Sub
  </code></pre>
  
  <p>I call this class from text lostfocus, click and some of doubted events, no luck .. </p>