Saturday, 19 October 2013

how to connect front end and back end in c#.net


1. First of all you need to download sql server r2 it consist of 5.28 gb nearly download at following link
http://kickass.to/microsoft-sql-server-2008-r2-x86-x64-t6685091.html
2. Second you need microsoft visual studio download the software following link
http://kickass.to/usearch/microsoft%20visual%20studio/

step: 1 open the sql server r2


step : 2 click connect and you may see this screen


step : 3 To create the data base


step : 4 Type Your Data Base Name


step : 5 Click the OK button


step : 6 Now your data base is created


step 7: Now you create table


step 8: Now type the column name and choose data type and then tick the allow not null chechbox and save by using ctrl+s and then enter the table name here i am using table name (logintable)
                                                                            1

2


step 9 now your table created.....


Step 10 : open new project in visual studio


Step 11 : Design a Form like this


Step 12 : Double click the save button



Step 13 : Add the namespace


Step 14 : Now you get the connection string following the methods in the visual studio ( ctrl+w+s) to open the solution explorer

Step 15 : Add a connection


Step 16 : Select Sql server connection

Step 17 : Select or Enter your server name( manually)
1.ENTER THE SERVER NAME
2 HERE YOUR SERVER NAME
3 TYPE YOUR SERVER NAME
4 SELECT YOUR DATA BASE NAME AND CLICK OK

Step : 18 Now your ready to connect the front end and back end...


Step : 19 Now you copy the connection string and past it to the coding 

Step : 20 Add the namespace

using System.Data;
using System.Data.SqlClient;

1. past your connection string in the coding.. see the screen shot u will understand
your coding : try this

 private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("Data Source=VIGNESH-PC;Initial Catalog=sampledatabase;Integrated Security=True");
            con.Open();
            SqlCommand cmd=new SqlCommand("insert into logintable values('"+textBox1.Text+"','"+textBox2.Text+"')",con);
            int r=cmd.ExecuteNonQuery();
            if (r > 0)
            {
                MessageBox.Show("inserted successfully");
            }
            con.Close();
        }

Step : 21 Execute your code press F5.


Step : 22 Check the database

Step : 23 Final Result


Thursday, 17 October 2013

Data Types For Front End and Back End in .Net

Jet Engine (Access)          Sql-Server                                                      C#

Text                                    char, nchar, varchar, nvarchar                           string
Memo                                 text, ntext, the above with len>255                   string
Byte                                    tinyint                                                               byte
Integer                                smallint                                                             short
Long Integer                        integer (int)                                                       int
Single                                  real                                                                   float
Double                                float                                                                 double
Replication ID                     uniqueidentifier                                                 Guid
Decimal                               decimal                                                            decimal
Date/Time                           smalldatetime, datetime, timestamp                    DateTime
Currency                             smallmoney, money                                          decimal
AutoNumber                       int + identity property                                       int
Yes/No                               bit                                                                    bool
OLE Object                        image                                                               byte[]
Hyperlink                             <no equivalent>                                               string

<no equivalent>                  binary, varbinary                                               byte[]

New Features in .Net Framework 4.5.1 Release Candidate

  • Automatic Binding Redirection of  Assemblies
  • Inorder to improve the performance of the web server and cloud server, it has the ability to collect diagnostics information.
  • In its garbage collection, it has the facility to explicity compact LOH(Large Object Heap).
  • ASP.NET app suspension, multi-core JIT improvements, and faster app startup after a .NET Framework update.
  • For More details about .net Framework 4.5.1 RC please visit http://msdn.microsoft.com/en-us/library/ms171868.aspx

date difference between two dates in c#.net code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; //  namespace for gridview
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient; //namespace for sqlconnection

namespace retrive_data_by_using_datetime
{
    public partial class Form1 : Form
    {
        public DateTime dt;
        public Form1()
        {
            InitializeComponent();
        }
//connection string
        SqlConnection con = new SqlConnection("Data Source=USER-PC;Initial Catalog=student;Integrated Security=True");
//insert date into the database using date time picker
        private void button1_Click(object sender, EventArgs e)
        {
            con.Open();
//here i am using  datetime picker for inserting date
            dt = Convert.ToDateTime(dateTimePicker1.Text);
            SqlCommand cmd = new SqlCommand("insert into tbl_Date values('"+dt+"')", con);
            int r = cmd.ExecuteNonQuery();
            if (r >0)
            {
                MessageBox.Show("saved successfully");
            }
            con.Close();
        }
//retrive (intermediate dates fromdate and todate) date from database and display in gridview
//in datebase when u create specify the datatype datetime
        private void button2_Click(object sender, EventArgs e)
        {
            string from = Convert.ToString(dtpfrom.Text);
            string to = Convert.ToString(dtpto.Text);
            DateTime fromdate = Convert.ToDateTime(from);
            DateTime todate = Convert.ToDateTime(to);
//sqlcommand for retrive date from date base
            SqlCommand cmd = new SqlCommand("select datea from tbl_Date where datea between convert(date,'"+fromdate.ToLocalTime()+"',0)and convert(date,'"+todate.ToLocalTime()+"',0)", con);
            SqlDataAdapter ad = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            ad.Fill(dt);
            dataGridView2.DataSource = dt;
           }
    }
}

age calculator by day,month,year

public string dal_AgeCalculator(DateTime dd-MMM-yy)
    {
        try
        {
            {
                DateTime today = DateTime.Now;
                TimeSpan span = today - (Convert.ToDateTime(dob));
                DateTime age = DateTime.MinValue + span;
                int yr = age.Year - 1;
                int mon = age.Month - 1;
                int day = age.Day - 1;
                string calcAge = string.Concat(yr.ToString(), "Years, ", mon.ToString(), "Months, ", day.ToString(), "days");
                return calcAge;
            }
           
        }
        catch
        {
            throw;
        }

    }

Register and login code c#

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

namespace login_form
{
    public partial class Form1 : Form
    {
        public string connection = "Data Source=user-PC;Initial Catalog=db_test;Integrated Security=True";
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(connection);
            con.Open();
            SqlCommand cmd = new SqlCommand("insert into userpassword values('"+txtuser.Text+"','"+txtpass.Text+"')",con);
            if (txtpass.Text == txtconformpass.Text)
            cmd.ExecuteNonQuery();
            MessageBox.Show("insert successfully");
            con.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(connection);
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from userpassword where username='"+textBox1.Text+"' and password='"+textBox2.Text+"' ",con);
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                MessageBox.Show("registered user");
            }
            else
                MessageBox.Show("please register 1st");
        }
    }
}




Wednesday, 16 October 2013

About Us

                 This site comprises of useful strategies about C# programming, Web designing, Photoshop, and latest Technologies in IT. We think this site will be useful for Application Development. The Users are requested to post their doubts and post their answers for the doubts posted in this site.