C# : Tutorial of Asp.net with c# and example

Example and code about windows application, web application, SQL, C#, WPF etc which is helpful to developer and programer.

Search This Blog

Code For do connection with ms access data base and explain concept with example and connection string using oledb connection.



In This Article we explain about Data Base Connection with MS Access Data Base 2007


Use Of Data Base connection: 
Data base connection is use for retrieve, insert, update, delete data from database by any system or software.


Following step for establish connection with Ms Access Data Base 2007
Step 1- Put following code in web.config file of asp.Net website

  
<connectionStrings>
    <add name="myconnectionstring" providerName="System.Data.OleDb" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\DB\Database1.accdb"/>
  </connectionStrings>

Step 2- Import Following two package in your code Behind (.aspx.cs) file where you want to do connection

using System.Data.OleDb;
using System.Configuration;

Step 3- We Do connection on load of page so put following code Page_load Event code Behind (.aspx.cs) file where you want to do connection.

OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString);
        try
        {
            conn.Open();
            msglitrl.Visible = true;
            msglitrl.Text = "Connection Done Successfully";
        }
        catch
        {

            msglitrl.Visible = true;
            msglitrl.Text = "Connection Fail.";
  }

Summary:

In Web.Config file

<connectionStrings>
    <add name="myconnectionstring" providerName="System.Data.OleDb" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\DB\Database1.accdb"/>
  </connectionStrings>

In code behind file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Configuration;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString);
        try
        {
            conn.Open();
            msglitrl.Visible = true;
            msglitrl.Text = "Connection Done Successfully";
        }
        catch
        {

            msglitrl.Visible = true;
            msglitrl.Text = "Connection Fail.";
        }
   }


In ASP.net open window form as popup box with example

♠ Posted by Unknown

How To Open second window form as popup on first window form in Asp.Net

You can create popup window of window form in asp.net or vb.net windows application it is use full to take input from user or give hint information etc. You need use following step for open window form as popup window  :

Step 1: Create one form in window application name mainform.

Step 2 : Create second form in window application give name popupform.

Step 3 : Create any one event, on which particular event you want to open popup window.

Example of event: button Onclick, Mouse Click,etc

Step 4: in particular event write following code:

In code  behind of mainform :

import 

using WindowsFormsApplication1;

in particular event :

new popupform().showDialog();



If You like our blog please share it and comment on it. Visit again.

http://aspdotnethelpmaster.blogspot.in/