C# CreateSqlServerConnection Snippets

C# CreateSqlServerConnection Snippets

11. June 2009

Read this article in your language IT | EN | DE | ES

<?xml version="1.0"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Create a Server based SQLConnection to SQL Server</Title>
      <Author>Microsoft Corporation</Author>
      <Description>Creates a SQL Connection providing replacements for the typical connection name/value pairs.  For this code snippet to compile, add a reference to System.Data.dll and System.Xml.dll.</Description>
      <Shortcut>adoCreateSqlConn</Shortcut>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>conn</ID>
          <Type>SqlConnection</Type>
          <ToolTip>Replace this with the name of the connection object.</ToolTip>
          <Default>conn</Default>
        </Literal>
        <Literal>
          <ID>serverName</ID>
          <Type>String</Type>
          <ToolTip>Replace this with the name of the server.</ToolTip>
          <Default>ServerName</Default>
        </Literal>
        <Literal>
          <ID>dataBaseName</ID>
          <Type>String</Type>
          <ToolTip>Replace this with the name of the database.</ToolTip>
          <Default>Northwind</Default>
        </Literal>
        <Literal>
          <ID>userId</ID>
          <Type>String</Type>
          <ToolTip>Replace this with the user name for connectivity to the database.</ToolTip>
          <Default>&lt;user name&gt;</Default>
        </Literal>
        <Literal>
          <ID>password</ID>
          <Type>String</Type>
          <ToolTip>Replace with the password that corresponds to your user name</ToolTip>
          <Default>&lt;your password&gt;</Default>
        </Literal>
        <Literal Editable="false">
          <ID>SqlConnectionClass</ID>
          <Function>SimpleTypeName(System.Data.SqlClient.SqlConnection)</Function>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[$SqlConnectionClass$ $conn$ = new $SqlConnectionClass$();
        $conn$.ConnectionString = @"Data Source=$serverName$;Initial Catalog=$dataBaseName$;Persist Security Info=True;User ID=$userId$;Password=$password$";$end$]]>        
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
FacebookDigg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

C# , C# Görsel Ders Egitim

Comments

8/14/2009 9:06:36 PM #
Tried to autotranslate you site not understand the writing any hope deutsch version?
8/16/2009 7:26:00 PM #
I don't like your template but your posts are quite good so I will check back!
8/27/2009 6:04:12 AM #
Hey I love your style I will subscribe for your feed please keep posting!

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Sayfa 0.046875 saniyede yuklendi.