Programming for Everybody

🔍 Search Access Database Directly from PowerPoint! | Smart Integration Tutorial With Source code

 




Private Sub CommandButton1_Click()

If id_txt.Text <> "" Then

Dim rst As New ADODB.Recordset

Dim conn As New ADODB.Connection

Dim strsql As String

conn.ConnectionString = "Provider=Microsoft.Ace.Oledb.12.0; Data Source=H:\contents\sports.accdb" _

& " ;Persist Security info = False"

    strsql = " SELECT * FROM Table2 Where id=" & id_txt.Text & ""

conn.Open


rst.Open strsql, conn

If rst.EOF Then

MsgBox "Data Not Found"

name_txt.Text = ""

age_txt.Text = ""

sport_txt.Text = ""

points_txt.Text = ""

date_txt.Text = ""

Else

name_txt.Text = rst.Fields("name1")

age_txt.Text = rst.Fields("age")

sport_txt.Text = rst.Fields("sport")

points_txt.Text = rst.Fields("points")

date_txt.Text = rst.Fields("date_reg")

   End If

       conn.Close

       End If

End Sub


full course C++ insert update and delete with Source code



#pragma once


namespace CppCLR_WinformsProjekt {


using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

using namespace System::Data::SqlClient;

/// <summary>

/// Zusammenfassung für Form1

/// </summary>

public ref class Form1 : public System::Windows::Forms::Form

{

SqlConnection^ conn = gcnew SqlConnection("Data Source=.;Initial Catalog=database10;Integrated Security=true");

public:

Form1(void)

{

InitializeComponent();

//

//TODO: Konstruktorcode hier hinzufügen.

//

}


protected:

/// <summary>

/// Verwendete Ressourcen bereinigen.

/// </summary>

~Form1()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::Label^  label1;

protected:

private: System::Windows::Forms::Label^  label2;

private: System::Windows::Forms::Label^  label3;

private: System::Windows::Forms::Label^  label4;


private: System::Windows::Forms::TextBox^  textBox2;

private: System::Windows::Forms::TextBox^  textBox3;

private: System::Windows::Forms::TextBox^  textBox4;

private: System::Windows::Forms::DataGridView^  dataGridView1;

private: System::Windows::Forms::Button^  button1;

private: System::Windows::Forms::Button^  button2;

private: System::Windows::Forms::Button^  button3;

private: System::Windows::Forms::Button^  button4;

private: System::Windows::Forms::Label^  idlbl;

private: System::Windows::Forms::Label^  code;

private: System::Windows::Forms::TextBox^  textBox1;


private:

/// <summary>

/// Erforderliche Designervariable.

/// </summary>

System::ComponentModel::Container ^components;


#pragma region Windows Form Designer generated code

/// <summary>

/// Erforderliche Methode für die Designerunterstützung.

/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.

/// </summary>

void InitializeComponent(void)

{

this->label1 = (gcnew System::Windows::Forms::Label());

this->label2 = (gcnew System::Windows::Forms::Label());

this->label3 = (gcnew System::Windows::Forms::Label());

this->label4 = (gcnew System::Windows::Forms::Label());

this->textBox2 = (gcnew System::Windows::Forms::TextBox());

this->textBox3 = (gcnew System::Windows::Forms::TextBox());

this->textBox4 = (gcnew System::Windows::Forms::TextBox());

this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());

this->button1 = (gcnew System::Windows::Forms::Button());

this->button2 = (gcnew System::Windows::Forms::Button());

this->button3 = (gcnew System::Windows::Forms::Button());

this->button4 = (gcnew System::Windows::Forms::Button());

this->idlbl = (gcnew System::Windows::Forms::Label());

this->code = (gcnew System::Windows::Forms::Label());

this->textBox1 = (gcnew System::Windows::Forms::TextBox());

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->BeginInit();

this->SuspendLayout();

// 

// label1

// 

this->label1->AutoSize = true;

this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->label1->Location = System::Drawing::Point(50, 26);

this->label1->Name = L"label1";

this->label1->Size = System::Drawing::Size(29, 24);

this->label1->TabIndex = 0;

this->label1->Text = L"ID";

// 

// label2

// 

this->label2->AutoSize = true;

this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->label2->Location = System::Drawing::Point(50, 111);

this->label2->Name = L"label2";

this->label2->Size = System::Drawing::Size(102, 24);

this->label2->TabIndex = 1;

this->label2->Text = L"Firstname";

// 

// label3

// 

this->label3->AutoSize = true;

this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->label3->Location = System::Drawing::Point(50, 178);

this->label3->Name = L"label3";

this->label3->Size = System::Drawing::Size(99, 24);

this->label3->TabIndex = 2;

this->label3->Text = L"Lastname";

// 

// label4

// 

this->label4->AutoSize = true;

this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->label4->Location = System::Drawing::Point(50, 250);

this->label4->Name = L"label4";

this->label4->Size = System::Drawing::Size(52, 24);

this->label4->TabIndex = 3;

this->label4->Text = L"Sum";

// 

// textBox2

// 

this->textBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->textBox2->Location = System::Drawing::Point(171, 111);

this->textBox2->Name = L"textBox2";

this->textBox2->Size = System::Drawing::Size(147, 29);

this->textBox2->TabIndex = 5;

// 

// textBox3

// 

this->textBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->textBox3->Location = System::Drawing::Point(171, 178);

this->textBox3->Name = L"textBox3";

this->textBox3->Size = System::Drawing::Size(147, 29);

this->textBox3->TabIndex = 6;

// 

// textBox4

// 

this->textBox4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->textBox4->Location = System::Drawing::Point(171, 236);

this->textBox4->Name = L"textBox4";

this->textBox4->Size = System::Drawing::Size(147, 29);

this->textBox4->TabIndex = 7;

// 

// dataGridView1

// 

this->dataGridView1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)

| System::Windows::Forms::AnchorStyles::Left)

| System::Windows::Forms::AnchorStyles::Right));

this->dataGridView1->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::Fill;

this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;

this->dataGridView1->Location = System::Drawing::Point(324, 53);

this->dataGridView1->Name = L"dataGridView1";

this->dataGridView1->Size = System::Drawing::Size(489, 501);

this->dataGridView1->TabIndex = 8;

this->dataGridView1->CellClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &Form1::dataGridView1_CellClick);

// 

// button1

// 

this->button1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));

this->button1->AutoSize = true;

this->button1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(255)),

static_cast<System::Int32>(static_cast<System::Byte>(192)));

this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->button1->Location = System::Drawing::Point(13, 576);

this->button1->Name = L"button1";

this->button1->Size = System::Drawing::Size(115, 42);

this->button1->TabIndex = 9;

this->button1->Text = L"New";

this->button1->UseVisualStyleBackColor = false;

this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);

// 

// button2

// 

this->button2->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));

this->button2->AutoSize = true;

this->button2->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(192)), static_cast<System::Int32>(static_cast<System::Byte>(255)),

static_cast<System::Int32>(static_cast<System::Byte>(192)));

this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->button2->Location = System::Drawing::Point(144, 576);

this->button2->Name = L"button2";

this->button2->Size = System::Drawing::Size(115, 42);

this->button2->TabIndex = 10;

this->button2->Text = L"Insert";

this->button2->UseVisualStyleBackColor = false;

this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);

// 

// button3

// 

this->button3->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));

this->button3->AutoSize = true;

this->button3->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(192)), static_cast<System::Int32>(static_cast<System::Byte>(255)),

static_cast<System::Int32>(static_cast<System::Byte>(255)));

this->button3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->button3->Location = System::Drawing::Point(285, 576);

this->button3->Name = L"button3";

this->button3->Size = System::Drawing::Size(115, 42);

this->button3->TabIndex = 11;

this->button3->Text = L"Update";

this->button3->UseVisualStyleBackColor = false;

this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);

// 

// button4

// 

this->button4->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));

this->button4->AutoSize = true;

this->button4->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(192)),

static_cast<System::Int32>(static_cast<System::Byte>(192)));

this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->button4->Location = System::Drawing::Point(422, 576);

this->button4->Name = L"button4";

this->button4->Size = System::Drawing::Size(115, 42);

this->button4->TabIndex = 12;

this->button4->Text = L"Delete";

this->button4->UseVisualStyleBackColor = false;

this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);

// 

// idlbl

// 

this->idlbl->AutoSize = true;

this->idlbl->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->idlbl->Location = System::Drawing::Point(140, 26);

this->idlbl->Name = L"idlbl";

this->idlbl->Size = System::Drawing::Size(0, 24);

this->idlbl->TabIndex = 13;

// 

// code

// 

this->code->AutoSize = true;

this->code->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->code->Location = System::Drawing::Point(50, 67);

this->code->Name = L"code";

this->code->Size = System::Drawing::Size(57, 24);

this->code->TabIndex = 14;

this->code->Text = L"code";

// 

// textBox1

// 

this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(0)));

this->textBox1->Location = System::Drawing::Point(171, 67);

this->textBox1->Name = L"textBox1";

this->textBox1->Size = System::Drawing::Size(147, 29);

this->textBox1->TabIndex = 15;

// 

// Form1

// 

this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->AutoSize = true;

this->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(192)), static_cast<System::Int32>(static_cast<System::Byte>(192)),

static_cast<System::Int32>(static_cast<System::Byte>(255)));

this->ClientSize = System::Drawing::Size(825, 670);

this->Controls->Add(this->textBox1);

this->Controls->Add(this->code);

this->Controls->Add(this->idlbl);

this->Controls->Add(this->button4);

this->Controls->Add(this->button3);

this->Controls->Add(this->button2);

this->Controls->Add(this->button1);

this->Controls->Add(this->dataGridView1);

this->Controls->Add(this->textBox4);

this->Controls->Add(this->textBox3);

this->Controls->Add(this->textBox2);

this->Controls->Add(this->label4);

this->Controls->Add(this->label3);

this->Controls->Add(this->label2);

this->Controls->Add(this->label1);

this->Name = L"Form1";

this->Text = L"Form1";

this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->EndInit();

this->ResumeLayout(false);

this->PerformLayout();


}

#pragma endregion

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {

load_data();

}

Void load_data() {

SqlCommand^ cmd = gcnew SqlCommand("Select * From Table1", conn);

SqlDataAdapter^ da = gcnew SqlDataAdapter(cmd);

DataTable^ dt = gcnew DataTable();

da->Fill(dt);

dataGridView1->DataSource = dt;

dataGridView1->ColumnHeadersDefaultCellStyle->Font = gcnew::System::Drawing::Font("Tahoma", 12, FontStyle::Bold);

dataGridView1->DefaultCellStyle->Font = gcnew::System::Drawing::Font("Arial", 12);

}

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

textBox1->Text = "";

textBox2->Text = "";

textBox3->Text = "";

textBox4->Text = "";

idlbl->Text = "";

}

private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {

for (int item = 0; item < dataGridView1->Rows->Count; item++)

{

if (dataGridView1->Rows[item]->IsNewRow)

continue;

if (textBox1->Text == dataGridView1->Rows[item]->Cells[1]->Value->ToString())

{

MessageBox::Show("Code exists before");

return;

}

}

SqlCommand^ cmd = gcnew SqlCommand("Insert Into Table1(code,fname,lname,sum1)Values(@code,@fname,@lname,@sum1)", conn);

cmd->Parameters->AddWithValue("@code", textBox1->Text->Trim());

cmd->Parameters->AddWithValue("@fname", textBox2->Text->Trim());

cmd->Parameters->AddWithValue("@lname", textBox3->Text->Trim());

cmd->Parameters->AddWithValue("@sum1", textBox4->Text->Trim());

conn->Open();

cmd->ExecuteNonQuery();

conn->Close();

MessageBox::Show("Inserted Successfully");

load_data();

}

private: System::Void dataGridView1_CellClick(System::Object^  sender, System::Windows::Forms::DataGridViewCellEventArgs^  e) {

int index;

index = e->RowIndex;

DataGridViewRow^ row = dataGridView1->Rows[index];

idlbl->Text = row->Cells[0]->Value->ToString();

textBox1->Text = row->Cells[1]->Value->ToString();

textBox2->Text = row->Cells[2]->Value->ToString();

textBox3->Text = row->Cells[3]->Value->ToString();

textBox4->Text = row->Cells[4]->Value->ToString();

}

private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {

if (dataGridView1->SelectedRows->Count == 0)

{

MessageBox::Show("Please Select row to Update.");

return;

}

String^ originalcode = dataGridView1->SelectedRows[0]->Cells[1]->Value->ToString();

for (int item = 0; item < dataGridView1->Rows->Count; item++)

{

if (dataGridView1->Rows[item]->IsNewRow)

continue;

String^ currentcode = dataGridView1->Rows[item]->Cells[1]->Value->ToString();

if (textBox1->Text == currentcode && currentcode != originalcode)

{

MessageBox::Show("code exists before");

return;

}

}

SqlCommand^ cmd = gcnew SqlCommand("Update Table1 Set code=@code,fname=@fname,lname=@lname,sum1=@sum1 Where id=@id", conn);

cmd->Parameters->AddWithValue("code", textBox1->Text->Trim());

cmd->Parameters->AddWithValue("@fname", textBox2->Text->Trim());

cmd->Parameters->AddWithValue("@lname", textBox3->Text->Trim());

cmd->Parameters->AddWithValue("@sum1", textBox4->Text->Trim());

cmd->Parameters->AddWithValue("@id", idlbl->Text);

conn->Open();

cmd->ExecuteNonQuery();

conn->Close();

MessageBox::Show("updated Successfully");

load_data();

}

private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {

if (dataGridView1->SelectedRows->Count == 0)

{

MessageBox::Show("Please Select row to delete.");

return;

}

String^ idtodelete = dataGridView1->SelectedRows[0]->Cells[0]->Value->ToString();

SqlCommand^ cmd = gcnew SqlCommand("Delete From Table1 Where id=@id", conn);

cmd->Parameters->AddWithValue("id", idtodelete);

conn->Open();

cmd->ExecuteNonQuery();

conn->Close();

MessageBox::Show("Deleted Successfully");

load_data();

textBox1->Text = "";

textBox2->Text = "";

textBox3->Text = "";

textBox4->Text = "";

idlbl->Text = "";

}

};

}

 

Programming in ASP.NET - Insert Update Delete in SQL Server in VB.NET with Source code

 



Imports System.Data

Imports System.Data.SqlClient

Imports System.Drawing

Partial Class _Default

    Inherits System.Web.UI.Page

    Dim conn As New SqlConnection("Data Source=.;Initial Catalog=students2;Integrated Security=True")

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim cmd As New SqlCommand("Insert into Table1(firstname,lastname,marks)Values(@firstname,@lastname,@marks)", conn)

        cmd.Parameters.AddWithValue("firstname", TextBox1.Text)

        cmd.Parameters.AddWithValue("lastname", TextBox2.Text)

        cmd.Parameters.AddWithValue("marks", TextBox3.Text)

        conn.Open()

        cmd.ExecuteNonQuery()

        conn.Close()

        result.Text = "Data Inserted Successfully"

        result.BackColor = Color.Green

        result.ForeColor = Color.White

        result.Font.Size = 16

        GridView1.DataBind()

    End Sub


    Private Sub form1_Load(sender As Object, e As EventArgs) Handles form1.Load

        GridView1.DataBind()

    End Sub


    Private Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged

        id1.Visible = True

        id1.Text = HttpUtility.HtmlDecode(GridView1.SelectedRow.Cells.Item(0).Text)

        TextBox1.Text = HttpUtility.HtmlDecode(GridView1.SelectedRow.Cells.Item(1).Text)

        TextBox2.Text = HttpUtility.HtmlDecode(GridView1.SelectedRow.Cells.Item(2).Text)

        TextBox3.Text = HttpUtility.HtmlDecode(GridView1.SelectedRow.Cells.Item(3).Text)

    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim cmd As New SqlCommand("Update Table1 Set firstname=@firstname,lastname=@lastname,marks=@marks Where id=@id", conn)

        cmd.Parameters.AddWithValue("id", id1.Text)

        cmd.Parameters.AddWithValue("firstname", TextBox1.Text)

        cmd.Parameters.AddWithValue("lastname", TextBox2.Text)

        cmd.Parameters.AddWithValue("marks", TextBox3.Text)

        conn.Open()

        cmd.ExecuteNonQuery()

        conn.Close()

        result.Text = "Data updated Successfully"

        result.BackColor = Color.Orange

        result.ForeColor = Color.White

        result.Font.Size = 16

        GridView1.DataBind()

    End Sub

    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

        Dim cmd As New SqlCommand("Delete from Table1 Where id=@id", conn)

        cmd.Parameters.AddWithValue("id", id1.Text)

        conn.Open()

        cmd.ExecuteNonQuery()

        conn.Close()

        result.Text = "Data Deleted Successfully"

        result.BackColor = Color.Brown

        result.ForeColor = Color.White

        result.Font.Size = 16

        GridView1.DataBind()

        id1.Visible = False

        TextBox1.Text = ""

        TextBox2.Text = ""

        TextBox3.Text = ""

    End Sub

End Class


programming in C# : System calculates installments and due dates With Source code



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;


namespace System_calculate_installments

{

    public partial class Form2 : Form

    {

        public Form2()

        {

            InitializeComponent();

        }

        DataTable dt = new DataTable();

        private void Form2_Load(object sender, EventArgs e)

        {

            dt.Columns.Add("Installment", typeof(string));

            dt.Columns.Add("Value", typeof(double));

            dt.Columns.Add("Due_date", typeof(DateTime));

            dataGridView1.DataSource = dt;

        }


        private void button1_Click(object sender, EventArgs e)

        {

            double price_v, adv_payment, installment_value, n_installments,final_installment;

            price_v = double.Parse(textBox1.Text);

            adv_payment = double.Parse(textBox2.Text);

            installment_value = double.Parse(textBox3.Text);

            n_installments = Math.Ceiling((price_v - adv_payment) / installment_value);

            final_installment = (price_v - adv_payment) % installment_value;

            dataGridView1.DataSource = null;

            dt.Clear();

            dataGridView1.DataSource = dt;

            for (int i = 1; i <= n_installments; i++)

            {

                var date_payment = (DateTime.Today.AddMonths(i)).ToString("MM-dd-yyyy");

                dt.Rows.Add("Installment" + i, textBox3.Text, date_payment);

            }

            if (final_installment != 0)

            {

                int lastrow = dataGridView1.Rows.Count - 1;

                dataGridView1.Rows[lastrow].Cells[1].Value = final_installment;

            }

        }

          

    }

}


📊 Filter RDLC Report Between Two Dates in C# | Step-by-Step Tutorial

 


code in Video:

private void button1_Click(object sender, EventArgs e)

        {

            this.Table_reg3TableAdapter.filterbydate(this.sportsDataSet.Table_reg3,Convert.ToDateTime(d1.Value).ToString(), Convert.ToDateTime(d2.Value).ToString());


            this.reportViewer1.RefreshReport();

        }


C# DataGridView Paging | WinForms Pagination Step-by-Step (With Source Code)

 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();

        }

        SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=sports;Integrated Security=true");

        int pagerows;

        private void count_pages()

        {

            SqlCommand cmd = new SqlCommand("Select Count(*) From Table_reg3", conn);

            conn.Open();

            int count1;

            count1 = int.Parse(cmd.ExecuteScalar().ToString());

            pagerows = Convert.ToInt32(Math.Ceiling(count1 / (double)10));

            label3.Text = pagerows.ToString();

        }

        private void load_data()

        {

            int f1 = Convert.ToInt32(label1.Text) * (int)10 - Convert.ToInt32(10 + 1);

            int t1 = Convert.ToInt32(label1.Text) * (int)10;

            SqlCommand cmd2 = new SqlCommand("Select * From(Select Row_Number() Over(Order By id) As rownumber,id,name1,age,sport,points From Table_reg3) tablerow Where rownumber Between " + f1 + "And " + t1 + "", conn);

            SqlDataAdapter da = new SqlDataAdapter(cmd2);

            DataTable dt = new DataTable();

            da.Fill(dt);

            dataGridView1.DataSource = dt;

        }

        private void Form2_Load(object sender, EventArgs e)

        {

            count_pages();

        }


        private void button1_Click(object sender, EventArgs e)

        {

            label1.Text = 1.ToString();

            load_data();

        }


        private void button2_Click(object sender, EventArgs e)

        {

            if(Convert.ToInt32(label1.Text)< pagerows)

            {

                label1.Text = (Convert.ToInt32(label1.Text) + (int)1).ToString();

                load_data();

            }

        }


        private void button3_Click(object sender, EventArgs e)

        {

            if (Convert.ToInt32(label1.Text) > (int)1)

            {

                label1.Text = (Convert.ToInt32(label1.Text) - (int)1).ToString();

                load_data();

            }

        }


        private void button4_Click(object sender, EventArgs e)

        {

            label1.Text = pagerows.ToString();

            load_data();

        }

    }

}