<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Search into a SQL 2005 database</Title>
      <Shortcut>SearchintoaSQL2005database</Shortcut>
      <Description>Search into a SQL 2005 database [VB.NET]</Description>
      <Author>Metaferia Amhayesus</Author>
      <HelpUrl>/PreviewSnippet.aspx?SnippetID=4e0bcad7-c265-4b3d-b4b2-50a98579559b</HelpUrl>
      <SnippetTypes>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="VB"><![CDATA[Private Sub butOk_Click(ByValsender As System.Object, ByVal e As System.EventArgs) Handles but_ok.Click
    Dim strConnection As String = "Data Source=your SQL data source;Initial Catalog=your database; Integrated Security=True"
    Dim cn As SqlClient.SqlConnection = New SqlClient.SqlConnection(strConnection)
    Dim ds As New DataSet
    Dim strSelect As String
    'strSelect As String 
    strSelect = "SELECT * FROM " & YourTable & " WHERE [Search Field] = '" & Me.txtName.Text & "'"
    Dim dscmd As New SqlClient.SqlDataAdapter(strSelect, cn)
    dscmd.Fill(ds, "your table")
    Me.Datagrid1.DataSource = ds
    Me.Datagrid1.DataMember = "your table"
    Dim con As Integer
    con = Me.BindingContext(ds, "your table").Count
    If con = 0 Then
    MessageBox.Show("Recourd could not be found")
    End If
    End Sub
]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>