﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Read Access Data into a Dataset</Title>
      <Author>Microsoft Corporation</Author>
      <Description>Loads the data from one table in an Access database into a DataSet object.</Description>
      <Shortcut>adoAccess</Shortcut>
    </Header>
    <Snippet>
      <References>
        <Reference>
          <Assembly>System.Data.dll</Assembly>
        </Reference>
        <Reference>
          <Assembly>System.Xml.dll</Assembly>
        </Reference>
      </References>
      <Imports>
        <Import>
          <Namespace>System</Namespace>
        </Import>
        <Import>
          <Namespace>System.Data</Namespace>
        </Import>
        <Import>
          <Namespace>System.Data.OleDb</Namespace>
        </Import>
        <Import>
          <Namespace>Microsoft.VisualBasic</Namespace>
        </Import>
      </Imports>
      <Declarations>
        <Literal>
          <ID>SQLString</ID>
          <Type>String</Type>
          <ToolTip>Replace with a SQL statement to retrieve the table.</ToolTip>
          <Default>"Select * from Topics"</Default>
        </Literal>
        <Literal>
          <ID>AccessFileName</ID>
          <Type>String</Type>
          <ToolTip>The file path to the Access file to be loaded</ToolTip>
          <Default>AccessFile.mdb</Default>
        </Literal>
      </Declarations>
      <Code Language="VB" Kind="method body"><![CDATA[Dim conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=$AccessFileName$;Persist Security Info=False"
Dim cmd As String = $SQLString$
Dim adapter As New OleDbDataAdapter(cmd, conn)
Dim topics As New DataSet
adapter.Fill(topics)
]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>