Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 186,436 times

Contents

Downloads

Related Categories

Creating a database connection - Opening and Closing

Tony Ho

Opening and Closing

After declaring your connection and setting the Connection String, the next thing to do is to open the connection, and also learn how to close it! ;)

Before you can perform any data reading or any forms of manipulation, you will have to open the connection first. Every connection object has a method we call Open as well as Close.

SQL:
   VB: SqlConn.Open()
   C#: SqlConn.Open();
OLE:
   VB: OleConn.Open()
   C#: OleConn.Open();

Wow pretty... simple isn't it?  The Close() Method is the same as the Open.  Just call it and It will close the corresponding conneciton object.... like in... OleConn.Close()

I have created a Sample application (created in VB) for you to skim over; just click 'Download Source Code' above. If there are any errors please inform me!! :) Have fun and I hope this 'tutorial' helps ya ;)

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 ...