16 April 2011

Connection String For dotnet framework Vb.net and C# Connectivity

Connection String For dotnet framework

Vb.net Connectivity

'VB
Dim connection as DbConnection = new SqlConnection()
connection.ConnectionString = _
"Server=.;Database=pubs;Trusted_Connection=true" connection.Open()

'Do lots of cool work here

connection.Close()

C# Connectivity

//C#

DbConnection connection = new SqlConnection();connection.ConnectionString =
"Server=.;Database=pubs;Trusted_Connection=true"; connection.Open();
//Do lots of cool work here connection.Close();


Creating an instance of the SqlConnection class using the SQL Server .NET provider creates
the DbConnection. The ConnectionString property is initialized to use the local machine (".")
and the database is set to pubs. Lastly, the connection uses a trusted connection for
authentication when connecting to SQL Server.

2 comments:

  1. This is a nice article..
    Its easy to understand ..
    And this article is using to learn something about it..

    c#, dot.net, php tutorial, Ms sql server

    Thanks a lot..!
    ri80

    ReplyDelete
  2. Also Check this link

    http://msdn.microsoft.com/en-us/library/aa720188%28VS.71%29.aspx

    ReplyDelete

Comments Welcome