Step By Step MsAccess DataBase Connection To Visual Studio 2012 Using OleDb Connection in C#.Net Window Application

MsAccess DataBase Connection To Visual Studio

MsAccess DataBase Connection To Visual Studio Using OleDb Connection in Window Application  Store Values To MsAccess DataBase in Particular Persional Computer(PC) C#.Net.

"MsAccess Close After Table & Field Created "

" If Open MsAccess Does Not Work In Visual Studio"


                                 DEMO





C# CODING


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;


namespace MsAccess_Creation
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Database3.accdb");
            con.Open();

    OleDbCommand cmd = new OleDbCommand("insert into Register(name,mobile)values('"+txtName.Text+"','"+Convert.ToInt32(txtMobileNumber.Text)+"')",con);

            cmd.ExecuteNonQuery();

            MessageBox.Show("Data Register");

        }
    }
}



First - Open - MsAccess Sheet






Next -Create New DataBase







Next - Create Table Fields & ID Automatic Generates







Next - Add New - Field - Select DataType = Text







Next - Change The Field Name = name






Next - Add New Field DataType=Number






Next - Click Save Button 






Next - Open - PopUp  Window - Change Table Name = Register - OK






If Want To Change The DataType  - Right Click Table Name- Go - To Design View 







Next - Change The DataType In Particular Fields







Next - Open The DataBase Source Folder - Copy To Change Another Colon(Drive)







Next - Change  To E Colon







Next - Server Explorer - Connect To Server 






Next - Select - Change Button 






Next - Change Data Source = Microsoft Access DataBase File.






Next - Select - Browse Button 






Next - Select DataBase  From E Drive - Open







Next - Get The DataBase From Drive Path 







Next - Click The Test Connection - Connection Succceded - OK






Next - Open DataBase From Server Explorer






Next - Select TextBox From  ToolBox - Change Id 






Next - Select TextBox From  ToolBox - Change Id 







Next - Go To - Data - Select  - OleDbConnection  






Next - OleDb Connection - Property - ConnectionString - DataBase Select 






Next - DataBase - Connection String Path Get 






Next - Add OleDb Connection Name Spaces - Insert Query Using OleDb Connection - Mobile Number Change To Integer Because DataType = Number






Next - Run[F5] - Enter Values To TextBox  - Register






Next - Data Register 






Next - Open Registered Data in Visual Studio








Next - Open MsAccess DataBase 






Next - Select - Table Name - Open






Next - Show Registered Data's From MsAccess DataBase










DataGridView Selected Row Cell Data To TextBox or Label in C#.Net Window Application

DataGridView Selected Row Cell Data To TextBox or Label


Selected DataGridView Row Cell Data Display To Textbox Or Label Using Window Application C#.Net.


                                             DEMO


                                
                               
                                        C# CODING


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication2
{

    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection
                (@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Drizzles\Documents\Visual Studio 2012\WindowsFormsApplication2\WindowsFormsApplication2\Database1.mdf;Integrated Security=True");
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from country", con);
            SqlDataAdapter adp=new SqlDataAdapter (cmd);
            DataTable dt=new DataTable ();
            adp.Fill(dt);
            dataGridView1 . DataSource=dt;

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
          
            DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];

          
            lblCountry.Text = row.Cells[0].Value.ToString();
           

            lblCity.Text = row.Cells[1].Value.ToString();

           
        }
    }
}




First - Add New window Form - Add DataBase Table Values





Next - Add The - DataGridView & Labels From ToolBox







Next - Page_Load  Bind The DataBase Values to DataGridView






Next - Double Click DataGridView - Get The Row Cell Values From DataGridview To Pass Labels








Next - Run[F5] - The Program Show The DataBase Values To DataGridView - Click The Particular Row - Cell Values Display The Labels









GridView To Another Page GridView Send Values Using DataSet or DataTable With Session In Asp.Net C#

GridView To Another Page GridView Send Values

One Gridview Display Values Send To Another Page Gridview  Using DataTable Or DataSet With Pass Session & Get Another Page Page_Load  Get Session bind To Gridview In Asp.Net C#.

                                     DEMO




HTML CODING(First Page)

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table><tr><td></td><td><asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" >
     <HeaderStyle BackColor="#FF3300" />
            <RowStyle BackColor="Silver" />
            <AlternatingRowStyle BackColor="#9999FF" />
</asp:GridView></td></tr>
            <tr><td colspan="2">  <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send Next Page" /></td></tr>
        </table>

        <br />
    </div>
    </form>
</body>
</html>

  
           HTML CODING(Second Page)


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>
</head>
<body>
    <form id="form1" runat="server">
      <div>
           
         <table><tr><td> </td><td>   <asp:GridView ID="GridView1" runat="server">

               <AlternatingRowStyle BackColor="#9999FF" />

                 <HeaderStyle BackColor="#FF3300" />
                      <RowStyle BackColor="#FF99FF" />           
            </asp:GridView>
             </td></tr></table>  
        </div>
    </form>
</body>

</html>



          C# CODING(First Page)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using System.Data.SqlClient;


public partial class Default4 : System.Web.UI.Page
{
    DataSet ds1;

    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["dbcon"].ToString());
        con.Open();

        SqlCommand cmd = new SqlCommand("select * from country", con);

        SqlDataAdapter adp = new SqlDataAdapter(cmd);
         ds1 = new DataSet();
        adp.Fill(ds1);

        GridView1.DataSource = ds1;
        GridView1.DataBind();

    }  
    protected void Button1_Click(object sender, EventArgs e)
    {
        Session["ds"] = ds1;
        Response.Redirect("Default3.aspx");
    }
}
  

                C# CODING(Second Page)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;


public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        DataSet ds2 = new DataSet();
        ds2 = (DataSet)Session["ds"];

        GridView1.DataSource = ds2;
        GridView1.DataBind();
      
    }
           
}


First - Add New Web Form - Insert DataBase Table Values 





Next - Add GridView & Button  From Toolbox in First Page





Next - Select Database Table Values To Bind GridView  & Session Pass DataSet ValuesTo Another Page






Next - Second Page - Add Gridview From Tool Box







Second Page - Page_Load - Get Session Values & Bind To  GridView






Next - Run[F5] - Display GridView Values - Click Button - Send DataSet Values To Next Page