Friday 21 September 2012

Database Operation in Visual C#

Controls
  • Three TextBox
  • Three Button
  • One Data GridView


Setting DataGridView..
  • Click Datagridview task An Arrow right top side of Gridview
  • Choose Data Source
  • Add Project Data Source
  • Select Database from Configuration Wizard Click Next
  • Click New Connection Click change from add connection wizard,select Microsoft Access Database file from  change data source wizard click ok
  • Browse your database mdb file from your computer, Test Connection > Ok >click next from configuration wizard
  • Visual studio prompt you to add your database in current project if you want to add click yes otherwise on
  • Select table from configuratiob wizard select your table and check fields which you want show in Datagridview and finish




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace AccessDemo
{
    public partial class Form1 : Form
    {
        OleDbConnection con = new OleDbConnection(@"provider=microsoft.jet.oledb.4.0;data source=D:\Raj\c#\Database\bsw.mdb");
        OleDbCommand com = new OleDbCommand();
        public Form1()
        {
            try
            {
                con.Open();
                com.Connection = con;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            InitializeComponent();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtRoll.Text == "" || txtName.Text == "" || txtCity.Text == "")
            {
                MessageBox.Show("Please fill all field properly");
            }
            else
            {
                             
                try
                {
               
                    com.CommandText = "insert into stu values(" + txtRoll.Text + ",'" + txtName.Text + "','" + txtCity.Text + "')";
                    com.ExecuteNonQuery();
                    MessageBox.Show("saved");
                    this.stuTableAdapter.Fill(this.bswDataSet.stu);

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
         

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'bswDataSet.stu' table. You can move, or remove it, as needed.
            this.stuTableAdapter.Fill(this.bswDataSet.stu);

        }

RollOver Feature on an Image in your website

Rollover is a feature in this effect when you move mouse on a
image then image change on that button instantly.This is possible with the help combination
of java script and css using inline mode



     <img src=a1.jpg height=100px width=100px
        onmouseover="this.src='a2.jpg'"
        onmouseout="this.src='a1.jpg'" />

   <img src=a1.jpg height=100px width=100px
        onmouseover="this.src='a2.jpg';this.style.border='outset 5px blue'"
        onmouseout="this.src='a1.jpg';this.style.border=''" />
     

RollOver and RollOut Effect on Button in a Website


<input type="button" value=" Girfa : Student Help " id="b1"    
      onmouseover="this.style.fontWeight='bold';"
      onmouseout="this.style.fontWeight='normal'";
      />


<input type="button" value=" Girfa : Student Help " id="b1"
      style="background-color:'blue'"
      onmouseover="this.style.backgroundColor='aqua';"
      onmouseout="this.style.backgroundColor='blue'";
      />



<input type="button" value="Girfa : Student Help"
      onmouseover="this.style.color='Blue';this.style.backgroundColor='yellow';this.style.border='outset 3px red'"
      onmouseout="this.style.color='';this.style.backgroundColor='';this.style.border=''" />


DLL in VB 6.0,VB.Net,C#

Hi......
DLL statds for Dynamic Link Library which comprise Business logic .At A huge level of 
Software development it is suitable to implement business login separately. 
DLL provides facility of reversibility means  ones you have been created a DLL 
for a task then many project can use your DLL, Like if you have a DLL of
Calculator logic then many Application can use it after importing DLL ij their project...

DLL in VB 6.0
  • Open VB 6.0 and select ActiveXdll
  • Change your final project name as you're going to make otherwise you may be face problem of name contradiction because default name of dll project is Project 1 and VB Standard exe has also same so change name of dll project or standard exe project
  • On Project explorer window change of class1 as your requirement
  • now make some procedure and function of your logic as showing in following picture
  • Save DLL project
  • For make DLL select File > Make Project1 DLL...
  • Now your DLL is ready to use
Develop by Raj Kumar

How to use This DLL
  • Open VB 6.0
  • Select Standard EXE
  • For add a DLL in your project ..
  • Go to Project > Refereneces.
  • Browse Your DLL File and click open
  • Now you can use DLL class
  • Make an object of class which you have made in your DLL project
  • Call function of your DLL class using . operator
After import DLL you can use it at anywhere here is code which you can use on a button click event

Private Sub Command1_Click()
    Dim ob As New Class1
    ob.Show
    
End Sub

Private Sub Command2_Click()
    Dim ob As New Class1
    MsgBox (ob.Sum(10, 20))
End Sub
DLL in C# and VB.Net

  • Open Visual studio 2008 File > Project > Select class library form template
  • Implement your function and logic inside class body
  • After implementing logic press f6 for build your DLL Project
  • For use a DLL in windows Application right click of root folder from solution explorer
  • Add References..
  • Browse your project DLL
  • Now make an object of class which you have named in DLL file
Code of DLL my DLL file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassLibrary1
{
    public class Class1
    {
        public int sum(int a,int b)
        {
            return a + b;
        }
    }
}