Articles → .NET → Adding Your Own Code Snippet In Visual Studio 2008
Adding Your Own Code Snippet In Visual Studio 2008
Creation Of Code Snippet
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0"></CodeSnippet>
</CodeSnippets>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>MyCode</Title>
</Header>
</CodeSnippet>
</CodeSnippets>
public DataSet GetResultSet(string query) {
DataSet resultSet = new DataSet();
using(OleDbConnection connection = new OleDbConnection("")) {
connection.Open();
using(OleDbDataAdapter adapter = new OleDbDataAdapter(query, connection)) {
adapter.Fill(resultSet);
}
}
return resultSet;
}
<Snippet>
<Code Language="CSharp">
<![CDATA[
public DataSet GetResultSet(string query)
{
DataSet resultSet = new DataSet();
using (OleDbConnection connection = new OleDbConnection(""))
{
connection.Open();
using (OleDbDataAdapter adapter = new OleDbDataAdapter(query, connection))
{
adapter.Fill(resultSet);
}
}
return resultSet;
}
] ]>
</Code>
</Snippet>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>MyCode</Title>
</Header>
<Snippet>
<Code Language="CSharp">
<![CDATA[
public DataSet GetResultSet(string query)
{
DataSet resultSet = new DataSet();
using (OleDbConnection connection = new OleDbConnection(""))
{
connection.Open();
using (OleDbDataAdapter adapter = new OleDbDataAdapter(query, connection))
{
adapter.Fill(resultSet);
}
}
return resultSet;
}
] ]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Click to Enlarge
Click to Enlarge
Click to Enlarge
Use Code Snippet In Your Project Later
Click to Enlarge
Click to Enlarge
Summary