Programming in VB.net: How to Make system backup databases in SQL server
With source code Excel macro VBA tutorial| insert update delete in sheet excel using entry form
Private Sub CommandButton1_Click()
Dim sheet_v As Worksheet
Set sheet_v = ThisWorkbook.Sheets("sheet1")
Dim lrow_v As Long
lrow_v = Sheets("sheet1").Range("A" & Rows.Count).End(xlUp).Row
sheet_v.Range("A" & lrow_v + 1).Value = TextBox1.Value
sheet_v.Range("B" & lrow_v + 1).Value = TextBox2.Value
sheet_v.Range("C" & lrow_v + 1).Value = TextBox3.Value
sheet_v.Range("D" & lrow_v + 1).Value = TextBox4.Value
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
'MsgBox ("Data inserted successfully")
Call load_data
End Sub
Sub load_data()
Dim sheet_v As Worksheet
Set sheet_v = ThisWorkbook.Sheets("sheet1")
Dim lrow_v As Long
lrow_v = Sheets("sheet1").Range("A" & Rows.Count).End(xlUp).Row
sheet_v.Range("A" & lrow_v + 1).Value = TextBox1.Value
With ListBox1
.ColumnCount = 4
.ColumnHeads = True
.ColumnWidths = "70,90,90,90"
.RowSource = "sheet1!A2:D" & lrow_v
End With
End Sub
Private Sub CommandButton2_Click()
Dim lrow_v As Long
lrow_v = Sheets("sheet1").Range("A" & Rows.Count).End(xlUp).Row
Dim i As Long
For i = 2 To lrow_v
If Sheets("sheet1").Cells(i, 1).Value = id.Text Then
Sheets("sheet1").Cells(i, 1).Value = TextBox1.Text
Sheets("sheet1").Cells(i, 2).Value = TextBox2.Text
Sheets("sheet1").Cells(i, 3).Value = TextBox3.Text
Sheets("sheet1").Cells(i, 4).Value = TextBox4.Text
End If
Next i
End Sub
Private Sub CommandButton3_Click()
Dim lrow_v As Long
lrow_v = Sheets("sheet1").Range("A" & Rows.Count).End(xlUp).Row
Dim i As Long
For i = 2 To lrow_v
If Sheets("sheet1").Cells(i, 1).Value = id.Text Then
Rows(i).Delete
End If
Next i
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
id.Value = ""
End Sub
Private Sub ListBox1_Click()
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.Value = ListBox1.Column(0)
TextBox2.Value = ListBox1.Column(1)
TextBox3.Value = ListBox1.Column(2)
TextBox4.Value = ListBox1.Column(3)
id.Value = ListBox1.Column(0)
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
Call load_data
End Sub
Important videos c#
Programming C# : Connect SQL server database with Visual Studio C# with source code
c# tutorial for beginners - insert update delete search in sql server database and print (With code)
Programming C#: insert, update and delete data in datagridview without using database
C#: update all data from datagridview to database at once
c# tutorial for beginners: How to store images update and delete in sql database
https://youtu.be/AwvrH8QK7DM
C# Tutorial : Retrieve data from Sql server database
https://youtu.be/lR_Ic_u8e90
C# Tutorial import data from Excel to SQL server
c# tutorial for beginners: Add Row Total To DataGridView Footer
c# tutorial for beginners: Insert Only Checked rows from datagridview into SQL database
C#: Get data in datagridview from two tables using inner join and (Left - right - full) outer join.
c# tutorial for beginners: Send data from datagridview to crystalreport without database in C#
c# tutorial for beginners: Print data from dataGridView In C#
c# tutorial for beginners: How to connect Microsoft access database to C#
c# tutorial for beginners: How to get the sum of checked RadioButton Values
How to get selected text and selected value of comboBox in C#
c# tutorial for beginners: Retrieve data from access database and navigation buttons
c# tutorial for beginners: Delete row from datagridview and sql server database at once in C#
c# tutorial for beginners - How to search multiple columns access database using one textBox in C#
C# Tutorial - message box exit application
c# tutorial for beginners - How to get the selected items in the combobox and show them in a listbox
C#: datagridview change cell backcolor based on value
c# tutorial for beginners - How to make validation on textbox in c#
How to fill combobox from sql server database and get selected value from a combobox in c#
How to search data in datagridview in c# without using database
c# tutorial for beginners - Insert all data of a dataGridView to access database at once with code
Programming C#: How to prevent duplicate data when insert to datagridview
C#: Search for value in DataGridView in a column(without database)
C#:Show and hide characters password
Programming in C # tutorial: Login Form in C # with SQL Server with source code
C# tutorial| connect with access database with password to retrieve data into textboxes -source code
using System;
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 connect_access_with_password
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection oledconn = new OleDbConnection(@"Provider=Microsoft.Ace.Oledb.12.0;Data Source=F:\ddd.accdb;Jet Oledb:Database Password=123456");
oledconn.Open();
OleDbCommand olecomm = new OleDbCommand("Select firstname,lastname,points from table1 Where id = @id", oledconn);
olecomm.Parameters.AddWithValue("id", textBox1.Text);
OleDbDataReader oledreader;
oledreader = olecomm.ExecuteReader();
if (oledreader.Read())
{
textBox2.Text = oledreader["firstname"].ToString();
textBox3.Text = oledreader["lastname"].ToString();
textBox4.Text = oledreader["points"].ToString();
}
else
{
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
MessageBox.Show("No data found");
}
oledconn.Close();
}
}
}
Filter Crystal Report using combobox in VB.net with source code
Imports System.Data.SqlClient
Public Class Form1
Dim conn As New SqlConnection("Data Source=.;Initial Catalog=sports;Integrated Security=true")
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
combo1()
report1()
End Sub
Private Sub combo1()
conn.Open()
Dim strsql As New SqlCommand("Select Distinct sport From Table1", conn)
Dim myreader As SqlDataReader = strsql.ExecuteReader
ComboBox1.Items.Clear()
While myreader.Read()
ComboBox1.Items.Add(myreader("sport"))
End While
conn.Close()
End Sub
Private Sub report1()
Dim cmd As New SqlCommand("Select * From Table1 Where sport Like '%" + ComboBox1.Text + "%'", conn)
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
Dim cr_report As New CrystalReport1
cr_report.SetDataSource(dt)
CrystalReportViewer1.ReportSource = cr_report
CrystalReportViewer1.Zoom(90%)
CrystalReportViewer1.Refresh()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
report1()
End Sub
End Class
c# tutorial for beginners - hotel management system project
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 Book__room
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
SqlConnection conn = new SqlConnection("Data Source=.;Initial catalog=hotel;Integrated Security=true");
string strsql;
SqlCommand cmd;
private void button1_Click(object sender, EventArgs e)
{
strsql = "insert into table1(room,startdate,enddate)Values(@room1,@start1,@end1)";
cmd = new SqlCommand(strsql, conn);
cmd.Parameters.AddWithValue("room1", comboBox1.Text);
cmd.Parameters.AddWithValue("start1", dateTimePicker1.Value.ToString());
cmd.Parameters.AddWithValue("end1", dateTimePicker2.Value.ToString());
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("The room reserved successfully");
}
private void button2_Click(object sender, EventArgs e)
{
conn.Open();
strsql = "Select * from table1 Where room=@room1 " +
"And ((@start1 >= startdate And @end1 <= enddate)" +
"Or (@start1 <= startdate And @end1 >= enddate)" +
"or (@start1 > startdate And @end1 > enddate And @start1<enddate)" +
"or (@start1 < startdate And @end1 < enddate And @end1>startdate))";
cmd = new SqlCommand(strsql, conn);
cmd.Parameters.AddWithValue("room1", comboBox1.Text);
cmd.Parameters.AddWithValue("start1", dateTimePicker1.Value.ToString());
cmd.Parameters.AddWithValue("end1", dateTimePicker2.Value.ToString());
SqlDataReader myreader = cmd.ExecuteReader();
if (myreader.Read())
{
MessageBox.Show("The room reserved From: " + myreader.GetValue(2).ToString() + " To: " + myreader.GetValue(3).ToString());
}
else
{
MessageBox.Show("The room not reserved before");
}
conn.Close();
}
}
}
VB.net: count and Insert Checked rows from DataGridView to sql Database with source code
Imports System.Data.SqlClient
Public Class Form2
Dim conn As New SqlConnection("Data Source=.;Initial Catalog=students;Integrated Security=true")
Dim countcheck As Integer
Private Sub DataGridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
If e.RowIndex < 0 Then Return
Dim ischecked As Boolean = CBool(DataGridView1.Rows(e.RowIndex).Cells(0).Value)
If ischecked Then
countcheck += 1
Else
countcheck -= 1
End If
Label1.Text = countcheck
End Sub
Private Sub DataGridView1_CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) Handles DataGridView1.CurrentCellDirtyStateChanged
If DataGridView1.IsCurrentCellDirty Then
DataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
End If
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim cmd As New SqlCommand("Select * from table1", conn)
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
DataGridView1.DataSource = dt
Dim checkboxcol As New DataGridViewCheckBoxColumn
checkboxcol.Width = 90
checkboxcol.Name = "checkboxcol"
checkboxcol.HeaderText = "Select student"
DataGridView1.Columns.Insert(0, checkboxcol)
DataGridView1.AllowUserToAddRows = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If countcheck > 0 Then
For Each row As DataGridViewRow In DataGridView1.Rows
Dim select1 As Boolean = Convert.ToBoolean(row.Cells("checkboxcol").Value)
If select1 Then
Dim cmd2 As New SqlCommand("Insert Into table7(firstname,lastname,marks)Values(@firstname,@lastname,@marks)", conn)
cmd2.Parameters.AddWithValue("firstname", row.Cells("firstname").Value)
cmd2.Parameters.AddWithValue("lastname", row.Cells("lastname").Value)
cmd2.Parameters.AddWithValue("marks", row.Cells("marks").Value)
conn.Open()
cmd2.ExecuteNonQuery()
conn.Close()
End If
Next
MessageBox.Show("Data Inserted successfully")
Else
MessageBox.Show("Please select students")
End If
End Sub
End Class