Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 186,476 times

Contents

Downloads

Related Categories

Creating a database connection - The Connection String

Tony Ho

The Connection String

By far one of the most important properties of the Connection object would have to be the Connection String!  It specifies where to connect, who is connectiong, what database to look at, etc.  The connection string is the backbone of the Connection object.  Ole and SQL both use Connection Strings.

The connection string is formatted like this:

"keyword=value;keyword=value;keyword=value;keyword=value"

You get the idea.

Some Keywords:
  SQL:
      database - what database to look at
      server - the server that you are connecting to
      trusted_connection - whether or not the machine is trusted (don't need uid/pw)
      uid - username
      pwd - password
  OLE:
      data source - Where the file is...
      provider - the Data provider

Examples:
    SQL:  "server=tonydev;database=northwind;uid=tony;pwd=hrmmm"
             "server=tonydev;database=northwind;trusted_connection=yes"

    OLE: "Provider=Microsoft.Jet.OLEDB.4.0; Data source=C:\tony.mdb"

Both the SQL and OLE Connection object have a property called 'ConnectionString', so the first thing you do after declaring the objects is set its connection string.

Currently attending Sophmore Year at Henry Clay High School, I have recently started on .NET and created a couple of sample projects. Working on my MCAD!

Comments

  • Re: [2459] Creating a database connection

    Posted by grace_qt on 21 Feb 2007

    hi i am trying to connect my vb. net prog tosql can yoi help me on how to do that..
    here is my codes..please tell my the error and what else do i need to put..
    Try

    <...

  • Re: Connection to database with password

    Posted by grace_qt on 21 Feb 2007

    Open connection to password protected Access database:

    "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; Jet OLEDB:Database Password=Your...

  • Connection to database with password

    Posted by vnz on 23 Apr 2006

    Hi..
    I'm trying to connect to an access database that is protected by password. but, it's always says "the database is being opened exclusively by another program" even I don't open other application...

  • hi Try this

    Posted by onlyamir007 on 08 May 2005

    string connStr;
               string qryStr;
               OleDbConnection dbConn;
               
    connStr = "Provider=Microsoft.Jet.OL...

  • c# database connection with m.s acesss

    Posted by ratnakar on 05 Aug 2003

    Plz reply me when i ma writing in c# using System.Data.Ado for the database connection with m.s acess then it is giving errror the type name space ado does not exist in in the class system.Data.ADO ...