MAURICE MUTETI Everything Goes Here
HOME
SAMPL E PAG E
C SHARP AND MYSQL DATABASE CRUD TUTORIAL Insert Update Search Delete And Display Data On DataGridView Using Visual Studio 2010
Donate Your donation helps to maintain the servers and content creation and will be much appreciated.
by admin February 16, 2020
Search …
C# (SHARP) AND MYSQL DATABASE CRUD TUTORIAL Insert Update Search
Delete And Display Data On DataGridView Using Visual Studio 2010
Recent Posts The primary reference “MySql.Data” could not be
This tutorial shows how to create crud(create, read, update, delete)
resolved because it was built
application using c#(C-Sharp) programming language. In this tutorial i
against the
have shared screenshots and video tutorials that equips you with basics
“.NETFramework,Version=v4.
of c# windows forms application and Mysql database. In order to
5” framework. This is a
understand this tutorial you need to have c# and sql knowledge. You don’t need to be advanced programmer but basics will be enough to understand this guide. After going through this guide you will be able to
higher version than the currently targeted framework “.NETFramework,Version=v4. 0”.
perform almost all c# crud operations. This tutorial also contains code snippets for both c# and sql. Am programming in windows 7, using Microsoft visual studio 2010 integrated development environment (IDE) , xampp localhost( With Apache, MySQL, and PHP already configured). To connect to Mysql database am using MySql.Data.dll (MySql .NET Connector) which can be downloaded from Mysql official website. You will see how to add the connector in visual studio 2010 in this tutorial.
How to Move Selected Code Up or Down in Visual Studio 2010 How To Download Mysql Connector For Visual Studio C Sharp Project C SHARP AND MYSQL DATABASE CRUD TUTORIAL Insert Update Search Delete And Display Data On DataGridView Using Visual Studio 2010
C SHARP AND MYSQL DATABASE CRUD TUTORIAL 61 How To Insert Update Search Delete And Display Data On DataGridView Complete Video Tutorial
Recent Comments
Table Of Contents 1. How To Insert Update Search Delete And Display Data On
Archives February 2020
DataGridView – Demo Video (Overview) – Project Walk-Through 2. How To Create A New Form 3. How To Display The Form At The Center Screen 4. How To Add Panel To A Form 5. How To Change Or Set Form Background Color
January 2020 December 2019 October 2019
6. How To Add Labels In A Form
September 2019
7. How To Add TextBoxes In A Form
July 2019
8. How To Add RadioButtons On A Form 9. How To Add CheckBoxes On A Form 10. How To Add Combobox On A Form
June 2019
Categories
11. How To Add Buttons On A Form 12. How To Add Table On A Form
Uncategorized
13. How To Add Picturebox On A Form 14. How To Add Image Icon On A Button 15. How To Browse And Display Image On PictureBox 16. How To Resize Image To Fit PictureBox 17. How To Filter Image Types (Png, Jpg, Gif) (OpenFileDialog) 18. How To Display Image Absolute Path (OpenFileDialog) 19. How To Download Mysql Connector For Visual Studio C# Project 20. How To Add Mysql Connector To Visual Studio 2010 Project 21. How To Create New MySql Database Using PHPMyAdmin 22. How To Connect To MySql Database – Part 1 23. How To Connect To MySql Database – Part 2 .Net Framework 4.5.2 Download 24. How To Connect To MySql Database – Part 3 Change The Target Framework 25. How To Connect To MySql Database – Part 4 – Check Connection [XAMPP] 26. How To Connect To MySql Database – Part 5 Opening Connection Function 27. How To Connect To MySql Database – Part 6 Closing Connection Function 28. How To Insert TextBox Text, Value, Data Into MySql Database – Part 1
29. How To Insert TextBox Text, Value, Data Into MySql Database – Part 2 30. How To Obtain Only The Filename (OpenFileDialog) Insert Into Db – Part 3 31. How To Insert Radio Button Values, Data Into MySql Database 32. How To Insert Checkbox Value, Data Into Database Using C# 33. How To Insert Combobox Selected Item, Value Into Mysql In C# 34. How To Save Or Insert Image Into Mysql Database In C# 35. How To Retrieve Data From Mysql And Display It On DataGridView In C# 36. How To Automatically Adjust Columns Width To Fit In The DataGridView In C# 37. How To Increase (Change Or Set) DataGridView Row Height In C# 38. How To Stretch An Image In C# DataGridView Fit Image In Column Row Cell 39. How To Create Getter And Setter, Constructor In C# – Shortcut 40. How To Read Mysql Data And Store Them In Array List C# 41. How To Populate (Bind) Datagridview From List Of Items In C# 42. How To Move a Line(Selected Code) Up or Down in Visual Studio 43. How To Check If Datagridview Row Is Selected Or Not In C# 44. How To Get Datagridview Currently Selected Row Index On Row click C#
45. How To Display Selected Row From Datagridview To Textboxes In C# 46. How To Display Selected Row Image From Datagridview To Picturebox C# 47. How To Display Selected Row Value From Datagridview To RadioButton C# 48. How To Display Selected Row Value From Datagridview To CheckBox C# 49. How To Display Selected Row Value From Datagridview To ComboBox C# 50. How To clear Or Reset a combobox On Button Click In C# 51. How To clear Or Reset Radio Button On Button Click In C# 52. How To clear Or Reset Check Box On Button Click In C# 53. How To clear Or Reset Text Boxes On Button Click In C# 54. How To clear Or Reset Image On A Picturebox On Button Click In C# 55. How To Make Only One Checkbox Checked At A Time C# 56. How To Disable Text Input [Editing] In TextBox In C# 57. How To Check If Input Fields Are Empty In C# 58. How To Delete Data From Table In MySql Using C# 59. How To Refresh Datagridview Rows After Change In MySql C# 60. How To Update Data From Table In MySql Using C#
61. How To Search Data From MySql and Filter in datagridview Table In C# 62. Fixing (GUI) Graphical User Interface 63. Complete Video Tutorial
How To Insert Update Search Delete And Display Data On DataGridView – Demo Video (Overview) – Project Walk-Through This is an overview showing complete project in action. In this video I am demonstrating how the application works.
To insert the data to Mysql database and display on DataGridView you need to start XAMPP Localhost. Xampp has Mysql where the data is stored. I am storing data (Text and images) in a single database. I have only one table created in the database. The table has different columns where different type of data is stored. ID column is the ‘Primary Key’ and auto-increments whenever you create or insert a new row. Images are stored in the database as Large BLOB(Binary Large OBject).
DEMO VIDEO C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #0 – How To Insert Update Search Delete And Display Data On DataGridView – Demo Video (Overview) – Project Walk-Through
How To Create A New Form Start Visual Studio 2010. Select the File menu, then New, then Project.
How To Create A New Form New Project
On the right pane choose/select windows forms application. Name the project and the solution: CSHARPANDMYSQLDATABASECRUD
Browse to the place on your computer where you wish Visual Studio 2010 to create the directory for your solution (keeping the check box selected). Click okay and you will be taken to a new forms window.
How To Create A New Form – New C SHarp Form Project
New form gets created immediately and you can resize it by increasing width and height. This can be done by dragging the edges or changing the forms properties.
How To Create A New Form – New Form
Solution Explorer Shows the files created for your project.
How To Create A New Form – Solution Explorer
In Solution Explorer, right click On Your Project Name And Select “Open Project In Windows Explorer”. This is only when you want to know the location where your c# project files are stored.
How To Create A New Form – Browse Folder Location
This is the location you chose when creating new project.
How To Create A New Form – Project Location
Form1.cs 1 2 3 4 5 6 7 8 9 10 11
using using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;
namespace CSHARPANDMYSQLDATABASE {
?
12 13 14 15 16 17 18 19
}
public partial class Form1 : Form { public Form1() { InitializeComponent(); } }
Form1.Designer.cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
? namespace CSHARPANDMYSQLDATABASE { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContaine
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if man protected override void Dispose(bool di { if (disposing && (components != nul { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated /// <summary> /// Required method for Designer suppor /// the contents of this method with th
28 29 30 31 32 33 34 35 36 37 38
/// </summary> private void InitializeComponent() { this.components = new System.Compon this.AutoScaleMode = System.Windows this.Text = "Form1"; }
}
#endregion
}
Program.cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
using using using using
System; System.Collections.Generic; System.Linq; System.Windows.Forms;
?
namespace CSHARPANDMYSQLDATABASE { static class Program { /// <summary> /// The main entry point for the applic /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRender Application.Run(new Form1()); } } }
VIDEO TUTORIAL
C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #1 – How To Create A New Form
How To Display The Form At The Center Screen By default the project might not start at the center of the screen, to start the window in the center screen, select it, then go to properties and set start position to center screen.
How To Display The Form At The Center Screen
When you run the project it should start at the center of the screen.
How To Display The Form At The Center Screen Positioned
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #2 â&#x20AC;&#x201C; How To Display The Form At The Center Screen
How To Add Panel To A Form Drag and drop panel from toolbox onto the form.
How To Add Panel To A Form
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR
C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #3 – How To Add Panel To A Form
How To Change Or Set Form Background Color Select the form, then go to properties and click next to “BackColor” and choose the desired color.
How To Change Or Set Form Background Color
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #4 â&#x20AC;&#x201C; How To Change Or Set Form Background Color
How To Add Labels In A Form Drag and drop label from toolbox onto the form.
How To Add Labels In A Form
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #5 – How To Add Labels In A Form
How To Add TextBoxes In A Form Drag and drop TextBox from toolbox onto the form.
How To Add TextBoxes On A Form
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #6 â&#x20AC;&#x201C; How To Add TextBoxes On A Form
How To Add RadioButtons On A Form Drag and drop RadioButton from toolbox onto the form.
How To Add RadioButtons On A Form
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #7 â&#x20AC;&#x201C; How To Add RadioButtons On A Form
How To Add CheckBoxes On A Form Drag and drop CheckBox from toolbox onto the form.
How To Add CheckBoxes On A Form
VIDEO TUTORIAL
C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #8 – How To Add CheckBoxes On A Form
How To Add Combobox On A Form Drag and drop ComboBox from toolbox onto the form.
How To Add Combobox On A Form
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #9 – How To Add Combobox On A Form
How To Add Buttons On A Form Drag and drop Button from toolbox onto the form.
How To Add Buttons On A Form
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #10 â&#x20AC;&#x201C; How To Add Buttons On A Form
How To Add DataGridView (Table) On A Form Drag and drop DataGridView from toolbox onto the form.
How To Add DataGridView On A Form
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #11 â&#x20AC;&#x201C; How To Add Table On A Form
How To Add Picturebox On A Form Drag and drop PictureBox from toolbox onto the form.
How To Add Picturebox On A Form
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #12 – How To Add Picturebox On A Form
How To Add Image Icon On A Button First you need to add image icons to your project resources folder. Right Click On your project from solution explorer, and select properties.
How To Add Image Icon On A Button â&#x20AC;&#x201C; Properties
Select resources tab. Then from Add resource dropdown, Select Add Existing File.
How To Add Image Icon On A Button â&#x20AC;&#x201C; Add Existing File
Select icons from your computer and click open.
How To Add Image Icon On A Button â&#x20AC;&#x201C; Select From PC
Select a button, then go to properties and click next to Image.
How To Add Image Icon On A Button
check â&#x20AC;&#x153;Project resource fileâ&#x20AC;? radio button and select an icon from the list. Then click Okay to add it on the button.
How To Add Image Icon On A Button – From Resources
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #13 â&#x20AC;&#x201C; How To Add Image Icon On A Button
How To Browse And Display Image On PictureBox Browse button opens dialog box where you can choose image from your computer.
How To Browse And Display Image On PictureBox
Choose one image from your PC and click open.
How To Browse And Display Image On PictureBox â&#x20AC;&#x201C; Dialog Box
After you click open the image is displayed on picturebox.
How To Browse And Display Image On PictureBox â&#x20AC;&#x201C; Image Selected
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14
//Browse image from the copmputer and display ?i private void button1_Click(object sender, Event { OpenFileDialog ofd = new OpenFileDialog(); //Filter Only Image with the following exte ofd.Filter = "Choose Only Images|*.png;*.jp //Dialog box title. ofd.Title = "Choose Image"; //If Open Button from opened dialog box is if (ofd.ShowDialog() == DialogResult.OK) { //Displaying image on picturebox. pictureBox1.Image = Image.FromFile(ofd //Displaying image path On Disabled tex
15 16 17 18 19
}
}
textBoxImagePath.Text = ofd.FileName; //Getting Image Filename textBoxImageName.Text = Path.GetFileNam
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #14 – How To Browse And Display Image On PictureBox
How To Resize Image To Fit PictureBox Click on picturebox to select it. Click on small right arrow icon located at the top right of the picturebox.
How To Resize Image To Fit PictureBox
Change Size Mode To “StretchImage”.
How To Resize Image To Fit PictureBox – Stretched
C# SOURCE CODE 1
? this.pictureBox1.SizeMode = System.Windows.Forms
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #15 – How To Resize Image To Fit PictureBox
How To Filter Image Types (Png, Jpg, Gif) (OpenFileDialog) This Filters Only File of type png, jpg and gif.
C# SOURCE CODE 1 2
? //Filter Only Image with the followin ofd.Filter = "Choose Only Images|*.png;*.jpg;*.g
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Q
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #16 â&#x20AC;&#x201C; How To Filter Image Types (Png, Jpg, Gif)
How To Display Image Absolute Path (OpenFileDialog) C# SOURCE CODE 1 2
//Displaying image path On Disabled textbox. textBoxImagePath.Text = ofd.FileName;
Image path is displayed in disabled textbox.
?
How To Display Image Absolute Path OpenFileDialog
C# SOURCE CODE 1 2
//Displaying image path On Disabled textbox. textBoxImagePath.Text = ofd.FileName;
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
?
C# AND MYSQL DATABASE CRUD TUTORIAL #17 – How To Display Image Absolute Path (OpenFileDialog)
How To Download Mysql Connector For Visual Studio C# Project Step 1. Go to https://dev.mysql.com/downloads/connector/net/ Select “.NET & Mono” from the dropdown list. Then Click Download Button Next to Zip File.
How To Download Mysql Connector NET For Visual Studio C# Project
Step 2 – Click “No Thanks, Just Start My Download”.
How To Download Mysql Connector NET For Visual Studio C# Project Zip
Step 3 â&#x20AC;&#x201C; Click Open To Open mysql connector/NET automatically with winrar when the download completes.
How To Download Mysql Connector NET For Visual Studio C# Project Zip Download
Step 4 â&#x20AC;&#x201C; Wait For The Download To Finish. You can view the download progress by clicking the down arrow as shown in the screenshot below. Am Using Mozilla FireFox Browser.
How To Download Mysql Connector NET For Visual Studio C# Project – Downloading
Step 5 – When the download finishes, Zip file Opens Automatically In Winrar. This is because I chose that option before the download started.
How To Download Mysql Connector NET For Visual Studio C# Project – Download Complete
Step 6 – Open any folder to check the files inside.
How To Download Mysql Connector NET For Visual Studio C# Project – File In Winrar
Step 7 – Select The Downloaded Zip file.
How To Download Mysql Connector NET For Visual Studio C# Project – Temp Folder
Step 8 – Right Click And Select Extract To A Folder.
How To Download Mysql Connector NET For Visual Studio C# Project – Extract To A Folder Inside Temp
Step 9 – The files are extracted to specified folder.
How To Download Mysql Connector NET For Visual Studio C# Project – Extracted To A Folder
Step 10 – If you extracted the files in temp folder, copy them to another location because this is a temporary folder. Anything stored here gets deleted in case you wipe your PC. (With software like CCleaner).
How To Download Mysql Connector NET For Visual Studio C# Project – Copy Folder To Desired Location
Step 11 – Open the Folder where the files are stored.
How To Download Mysql Connector NET For Visual Studio C# Project – Open Folder From Desktop
Step 12 – Here you can see mysql.data.dll file. This is the file you add to your integrated development environment (IDE) like Visual Studio 2010.
How To Download Mysql Connector NET For Visual Studio C# Project – NET Connector File
VIDEO TUTORIAL How To Download Mysql Connector/NET …
Watch later
Share
How To Download Mysql Connector/NET For Visual Studio C# Project
How To Add Mysql Connector To Visual Studio 2010 Project Right Click on project name from solution explorer. Select add reference.
How To Display Image Absolute Path OpenFileDialog â&#x20AC;&#x201C; Right Click Then Add Reference
click on browse tab. Locate the connector folder and open it. Select MySql.Data.Dll. Click Ok.
How To Display Image Absolute Path OpenFileDialog â&#x20AC;&#x201C; Browse Mysql Connector File
Mysql.Data is added to references section. This means mysql connector/NET has been added in your project successfully.
How To Display Image Absolute Path OpenFileDialog â&#x20AC;&#x201C; Added To Reference
This is the folder where MySql Connector/NET is found.
How To Add Mysql Connector To Visual Studio 2010 Project – Connector Folder
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #18 – How To Add Mysql Connector To Visual Studio
How To Create New MySql Database Using PHPMyAdmin Start xampp control panel. If you have shortcut click it to start xampp. If you don’t, Start xampp from installation location.
How To Create New MySql Database Using PHPMyAdmin â&#x20AC;&#x201C; Xampp Location
Start both Apache and Mysql.
How To Create New MySql Database Using PHPMyAdmin â&#x20AC;&#x201C; Start Xampp
Both services are now running.
How To Create New MySql Database Using PHPMyAdmin â&#x20AC;&#x201C; Start apache and mysql
Click Admin next to mysql to stat PHPMyadmin GUI. On your browser.
How To Create New MySql Database Using PHPMyAdmin â&#x20AC;&#x201C; Admin Next To mysql
Click New To create new database.
How To Create New MySql Database Using PHPMyAdmin â&#x20AC;&#x201C; phpmyadmin Homepage
Enter database name and click create button.
How To Create New MySql Database Using PHPMyAdmin â&#x20AC;&#x201C; Enter Database Name
The database is created without any table inside.
How To Create New MySql Database Using PHPMyAdmin â&#x20AC;&#x201C; Database Created
On the left pane under created database, click on new, to create new table. Enter table name and add required columns and their datatypes.
How To Create New MySql Database Using PHPMyAdmin â&#x20AC;&#x201C; Create New Table
To check the table structure click on structure tab.
How To Create New MySql Database Using PHPMyAdmin – Table Structure
To run a query for selecting all data from the table click on “SQL” tab. Enter query in the text area.
How To Create New MySql Database Using PHPMyAdmin – Select All
Click “GO” to run your query.
How To Create New MySql Database Using PHPMyAdmin â&#x20AC;&#x201C; All Table Data Selected
SQL QUERY 1 2 3 4 5 6 7 8 9 10 11 12
---------
phpMyAdmin SQL Dump version 4.9.0.1 https://www.phpmyadmin.net/ Host: 127.0.0.1 Generation Time: Feb 20, 2020 at 02:46 PM Server version: 10.3.15-MariaDB PHP Version: 7.3.6
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION;
?
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
SET time_zone = "+00:00"; /*!40101 /*!40101 /*!40101 /*!40101
SET SET SET SET
@OLD_CHARACTER_SET_CLIENT=@@CHARAC @OLD_CHARACTER_SET_RESULTS=@@CHARA @OLD_COLLATION_CONNECTION=@@COLLAT NAMES utf8mb4 */;
--- Database: `csharpandmysqlcrudinsertupdatedel -CREATE DATABASE IF NOT EXISTS `csharpandmysqlcr USE `csharpandmysqlcrudinsertupdatedeleteselect -- ---------------------------------------------- Table structure for table `csharpandmysqlcru -DROP TABLE IF EXISTS `csharpandmysqlcrudinsertu CREATE TABLE IF NOT EXISTS `csharpandmysqlcrudi `Id` int(11) NOT NULL AUTO_INCREMENT, `FirstName` varchar(50) NOT NULL, `LastName` varchar(50) NOT NULL, `Email` varchar(50) NOT NULL, `Gender` varchar(20) NOT NULL, `Language` varchar(50) NOT NULL, `Country` varchar(50) NOT NULL, `ImageName` varchar(50) NOT NULL, `ImagePath` varchar(255) NOT NULL, `ImageBlob` longblob NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARS --- Dumping data for table `csharpandmysqlcrudin --
52 53 54 55 56
COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTE /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACT /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATIO
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #19 – How To Create New MySql Database – PHPMyAdmin
How To Connect To MySql Database – Part 1
To work with database you need to be connected.
MySQLDatabaseConnection.cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
using using using using using using using
System; System.Collections.Generic; System.Linq; System.Text; MySql.Data.MySqlClient; System.Data; System.Windows.Forms;
?
namespace JAVAANDMYSQLDATABASECRUD { public class MySQLDatabaseConnection { MySqlConnection connection = new MySqlC //Function to get connection public MySqlConnection getDatabaseConne { return connection; } //Open Connection function public void openDBConnection() { //Check if Connection Is Closed And if (connection.State == ConnectionS { //MessageBox.Show("Connection O connection.Open(); } }
33 34 35 36 37 38 39 40 41 42 43 44 45 46
//Close Connection function public void closeDBConnection() { //Check if Connection Is Open And C if (connection.State == ConnectionS { //MessageBox.Show("Connection C connection.Close(); } } }
}
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #20 – How To Connect To MySql Database – Part 1
How To Connect To MySql Database â&#x20AC;&#x201C; Part 2 .Net Framework 4.5.2 Download To download .Net Framework 4.5.2 go to https://www.microsoft.com/en-us/download/details.aspx?id=42642 Click Download button to begin the download process.
How To Download And Install Net Framework 4 5 2 – Official Microsoft Website
When the download finishes, run the downloaded file and follow all the steps till .Net Framework 4.5.2 is completely installed.
How To Download And Install Net Framework 4 5 2 – Downloaded and installed
VIDEO TUTORIAL C# AND MYSQL DATABASE #21 - How To …
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #21 – How To Connect To MySql Database – Part 2 .Net Framework 4.5.2 Download
How To Connect To MySql Database – Part 3 Change The Target Framework I had to change the configuration xml file targeted framework to 4.5.2 from 4.0 because i was getting this error “The primary reference “MySql.Data” could not be resolved because it was built against the “.NETFramework,Version=v4.5” framework. This is a higher version than the currently targeted framework “.NETFramework,Version=v4.0”.”.
How To Change The Target Framework In Visual Studio 2010 by updating the .csproj Xml File This solution fixes the above error. I have .NETFramework Version=v4.5.2 already installed in windows 7. Am going to point my project to this version in my settings.
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – FW 452
To Check currently selected framework version right click on your project then select properties.
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Properties
Click on application tab and check the target framework. You can choose different framework from the drop down list.
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Target Framework
Right click on your project and select “Unload Project”.
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File â&#x20AC;&#x201C; Unloading project
Right click on unloaded project and select edit (ProjectName) .csproj.
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File â&#x20AC;&#x201C; Edit .csproj
Change The following sections to targeted framework version.
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Before Changing FW
In this case am targeting .NET Framework version 4.5.2
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – XML File
Save your settings then right click on project name and select “Reload Project”.
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File â&#x20AC;&#x201C; Reload Project
Click Okay When you are prompted to close open document.
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File – Close Open Doc
Project is reloaded, And it’s available in solution explorer.
How To Change The Target Framework In Visual Studio 2010 by updating the dot csproj Xml File â&#x20AC;&#x201C; Project Reloaded
Try to run your project again and it should run without any problem.
.CSPROJ XML FILE AFTER RECTIFYING THE ERROR. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
? <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.5.2" DefaultTargets=" <PropertyGroup> <Configuration Condition=" '$(Configuratio <Platform Condition=" '$(Platform)' == '' <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{8C91C6DC-A0DD-4EA2-AA0E-5C49 <OutputType>WinExe</OutputType> <AppDesignerFolder>Properties</AppDesigner <RootNamespace>JAVAANDMYSQLDATABASECRUD</R <AssemblyName>JAVAANDMYSQLDATABASECRUD</As <TargetFrameworkVersion>v4.5.2</TargetFram <TargetFrameworkProfile> </TargetFrameworkProfile> <FileAlignment>512</FileAlignment> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration) <PlatformTarget>x86</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConsta <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration) <PlatformTarget>x86</PlatformTarget>
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
<DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <PropertyGroup> <StartupObject> </StartupObject> </PropertyGroup> <ItemGroup> <Reference Include="MySql.Data, Version=8 <SpecificVersion>False</SpecificVersion> <HintPath>..\..\..\..\..\Downloads\mysql </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExt <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Deployment" /> <Reference Include="System.Drawing" /> <Reference Include="System.Windows.Forms" <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Form1.cs"> <SubType>Form</SubType> </Compile> <Compile Include="Form1.Designer.cs"> <DependentUpon>Form1.cs</DependentUpon> </Compile> <Compile Include="MySQLDatabaseConnection <Compile Include="Person.cs" /> <Compile Include="PersonData.cs" /> <Compile Include="Program.cs" />
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
<Compile Include="Properties\AssemblyInfo <EmbeddedResource Include="Form1.resx"> <DependentUpon>Form1.cs</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="Properties\Reso <Generator>ResXFileCodeGenerator</Genera <LastGenOutput>Resources.Designer.cs</La <SubType>Designer</SubType> </EmbeddedResource> <Compile Include="Properties\Resources.Des <AutoGen>True</AutoGen> <DependentUpon>Resources.resx</Dependent <DesignTime>True</DesignTime> </Compile> <None Include="app.config" /> <None Include="Properties\Settings.setting <Generator>SettingsSingleFileGenerator</ <LastGenOutput>Settings.Designer.cs</Las </None> <Compile Include="Properties\Settings.Desi <AutoGen>True</AutoGen> <DependentUpon>Settings.settings</Depend <DesignTimeSharedInput>True</DesignTimeS </Compile> </ItemGroup> <ItemGroup> <None Include="Resources\x-button.png" /> </ItemGroup> <ItemGroup> <None Include="Resources\plus-1.png" /> </ItemGroup> <ItemGroup> <None Include="Resources\refresh-24.png" / </ItemGroup> <ItemGroup> <None Include="Resources\x-button1.png" /> </ItemGroup> <ItemGroup> <None Include="Resources\clear.png" />
109 110 111 112 113 114 115 116 117 118
</ItemGroup> <Import Project="$(MSBuildToolsPath)\Microso <!-- To modify your build process, add your Other similar extension points exist, s <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>
VIDEO TUTORIAL C# AND MYSQL TUTORIAL #22 - How To …
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #22 – How To Connect To MySql Database – Part 3 Changing The Target Framework
How To Connect To MySql Database – Part 4 – Check Connection [XAMPP] Check if database connection is established.
VIDEO TUTORIAL C# AND MYSQL TUTORIAL #23 - How To …
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #23 – How To Connect To MySql Database – Part 4 – Check Connection [XAMPP]
How To Connect To MySql Database – Part 5 Opening Connection Function To work on database you need to open database connection.
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10
//Open Connection function
?
public void openDBConnection() { //Check if Connection Is Closed And Open It if (connection.State == ConnectionState.Clo { //MessageBox.Show("Connection Opened"); connection.Open(); } }
VIDEO TUTORIAL C# AND MYSQL TUTORIAL #24 - How To …
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #24 – How To Connect To MySql Database – Part 5 Opening Connection Function
How To Connect To MySql Database – Part 6 Closing Connection Function It’s a good practice to close database connection after running queries.
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11
//Close Connection function
?
public void closeDBConnection() { //Check if Connection Is Open And Close It if (connection.State == ConnectionState.Ope { //MessageBox.Show("Connection Closed"); connection.Close(); } }
VIDEO TUTORIAL C# AND MYSQL TUTORIAL #25 - How To …
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #25 – How To Connect To MySql Database – Part 6 Closing Connection Function
How To Insert TextBox Text, Value, Data Into MySql Database – Part 1 The values from textboxes are inserted to database varchar columns.
VIDEO TUTORIAL C# AND MYSQL TUTORIAL #26 - How To I… I…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #26 – How To Insert TextBox Text Or Value Or Data Into MySql Database – Part 1
How To Insert TextBox Text, Value, Data Into MySql Database – Part 2
How To Insert TextBox Text Value Data Into MySql Database
VIDEO TUTORIAL
C# AND MYSQL TUTORIAL #27 - How To I… I…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #26 – How To Insert TextBox Text Or Value Or Data Into MySql Database – Part 1
How To Obtain Only The Filename (OpenFileDialog) Insert Into Db – Part 3 This is extracting the file name from the full path.
C# SOURCE CODE 1 2
? //Getting Image Filename textBoxImageName.Text = Path.GetFileName(ofd.Fil
VIDEO TUTORIAL
C# AND MYSQL TUTORIAL #28 - How To …
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #28 – How To Obtain Only The Filename (OpenFileDialog) Insert Into Db – Part 3
How To Insert Radio Button Values, Data Into MySql Database Radio button values are inserted to database as varchar.
How To Insert Radio Button Values Data Into MySql Database
VIDEO TUTORIAL C# AND MYSQL CRUD TUTORIAL #29 - H… H…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #29 â&#x20AC;&#x201C; How To Insert Radio Button Values Or Data Into Mysql Database
How To Insert Checkbox Value, Data Into Database Using C# CheckBox values are saved in tables varchar column.
How To Insert Checkbox Value Data Into Database Using C
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #30 – How To Insert Checkbox Values Or Data Into Database
How To Insert Combobox Selected Item, Value Into Mysql In C# Selected value from dropdown is inserted to tables varchar column.
How To Insert Combobox Selected Item Value Into Mysql In C
VIDEO TUTORIAL C# AND MYSQL CRUD TUTORIAL #31 - H… H…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #31 – How To Insert Combobox Selected Item Or Value Into Mysql Database
How To Save Or Insert Image Into Mysql Database In C# Image from picturebox is inserted to large BLOB column.
How To Save Or Insert Image Into Mysql Database
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #32 – How To Save Or Insert Image Into Mysql Database
How To Retrieve Data From Mysql And Display It On DataGridView In C# All rows are displayed In DataGridView from Mysql table when you run the application. Also the datagridview refreshes when you : insert new row(data), delete a row, update a row etc…..
Person.cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
using using using using
System; System.Collections.Generic; System.Linq; System.Text;
?
namespace JAVAANDMYSQLDATABASECRUD { class Person { //Shortcut For Creating properties and // Type propfull and double click Tab private private private private private private private private private private
int _Id; string _FirstName; string _LastName; string _Email; string _Gender; string _Language; string _Country; string _ImageName; string _ImagePath; byte[] _ImageBlob;
//To create Constructor Type ctor, then public Person() { } public int Id { get { return _Id; } set { _Id = value; } }
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
public string FirstName { get { return _FirstName; } set { _FirstName = value; } } public string LastName { get { return _LastName; } set { _LastName = value; } } public string Email { get { return _Email; } set { _Email = value; } } public string Gender { get { return _Gender; } set { _Gender = value; } } public string Language { get { return _Language; } set { _Language = value; } } public string Country { get { return _Country; } set { _Country = value; } } public string ImageName { get { return _ImageName; }
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
}
set { _ImageName = value; }
public string ImagePath { get { return _ImagePath; } set { _ImagePath = value; } } public byte[] ImageBlob { get { return _ImageBlob; } set { _ImageBlob = value; } }
}
}
PersonData.cs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
using using using using using using
System; System.Collections.Generic; System.Linq; System.Text; System.Windows.Forms; MySql.Data.MySqlClient;
?
namespace JAVAANDMYSQLDATABASECRUD { class PersonData { MySQLDatabaseConnection dbCONN = new My public List<Person> PersonList(string v { List<Person> personList = new List< String selectFromMysqlDatabase = "S
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
MySqlCommand command; MySqlDataReader reader; Person person; dbCONN.openDBConnection(); try { command = new MySqlCommand(sele reader = command.ExecuteReader while (reader.Read()) { person = new Person(); person.Id = Convert.ToInt32 //.GetInt32(reader[0].T person.FirstName = reader[1 person.LastName = reader[2] person.Email = reader[3].To person.Gender = reader[4].T person.Language = reader[5] person.Country = reader[6] person.ImageName = reader[7 person.ImagePath = reader[8 person.ImageBlob = (byte[]) }
personList.Add(person);
} catch (Exception err) { MessageBox.Show("Error " + err } finally { //reader.Close(); //command.Dispose(); dbCONN.closeDBConnection(); }
57 58 59 60 61 62
return personList;
}
}
}
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
? private void Form1_Load(object sender, EventArg { //Fill Datagridview with data from mysql da refreshDatagridView("");
} private void refreshDatagridView(string searchV { dataGridView1.AutoSizeColumnsMode = DataGri dataGridView1.RowTemplate.Height = 45; BindingSource bsource = new BindingSource() PersonData pData = new PersonData(); bsource.DataSource = pData.PersonList(searc dataGridView1.DataSource = bsource;
}
//Fit Image In DataGridView Cell DataGridViewImageColumn dGVimageColumn = (D dGVimageColumn.ImageLayout = DataGridViewIm
How To Retrieve Data From Mysql And Display It On DataGridView In C
VIDEO TUTORIAL C# AND MYSQL CRUD TUTORIAL #33 - H… H…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #33 â&#x20AC;&#x201C; How To Retrieve Data From Mysql And Display It On DataGridView
How To Automatically Adjust Columns Width To Fit In The DataGridView In C# This makes the column fit to the datagridview. Sometimes columns might be less than the datagridview size. This Enable them To adjust automatically to fill datagridview.
Automatically Adjust Columns Width To Fit In The DataGridView In C
C# SOURCE CODE 1
this.dataGridView1.AutoSizeColumnsMode = System?
VIDEO TUTORIAL C# AND MYSQL TUTORIAL #34 - How To â&#x20AC;¦
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #34 – How To Automatically Adjust Columns Width To Fit In The DataGridView
How To Increase (Change Or Set) DataGridView Row Height In C# It is important to increase or decrease the row height for clear view of the cell content.
C# SOURCE CODE 1
dataGridView1.RowTemplate.Height = 45;
?
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #35 – How To Increase (Change Or Set) DataGridView Row Height
How To Stretch An Image In C# DataGridView Fit Image In Column Row Cell Images should be visible in full format. This is done by stretching them to fit the cell.
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #36 – How To Stretch An Image to Fit In DataGridView Cell
How To Create Getter And Setter, Constructor In C# – Shortcut Getters, setters and constructors simplify the whole coding process and reduce the code.
C# SOURCE CODE 1 2 3 4
using using using using
System; System.Collections.Generic; System.Linq; System.Text;
?
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
namespace JAVAANDMYSQLDATABASECRUD { class Person { //Shortcut For Creating properties and // Type propfull and double click Tab private private private private private private private private private private
int _Id; string _FirstName; string _LastName; string _Email; string _Gender; string _Language; string _Country; string _ImageName; string _ImagePath; byte[] _ImageBlob;
//To create Constructor Type ctor, then public Person() { } public int Id { get { return _Id; } set { _Id = value; } } public string FirstName { get { return _FirstName; } set { _FirstName = value; } } public string LastName
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
{ }
get { return _LastName; } set { _LastName = value; }
public string Email { get { return _Email; } set { _Email = value; } } public string Gender { get { return _Gender; } set { _Gender = value; } } public string Language { get { return _Language; } set { _Language = value; } } public string Country { get { return _Country; } set { _Country = value; } } public string ImageName { get { return _ImageName; } set { _ImageName = value; } } public string ImagePath { get { return _ImagePath; } set { _ImagePath = value; }
83 84 85 86 87 88 89 90 91 92 93
} public byte[] ImageBlob { get { return _ImageBlob; } set { _ImageBlob = value; } }
}
}
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #37 – How To Create Getters Setters And Constructor – Shortcut
How To Read Mysql Data And Store Them In Array List C# All rows from mysql database are stored in an arraylist function.
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
using using using using using using
System; System.Collections.Generic; System.Linq; System.Text; System.Windows.Forms; MySql.Data.MySqlClient;
?
namespace JAVAANDMYSQLDATABASECRUD { class PersonData { MySQLDatabaseConnection dbCONN = new My public List<Person> PersonList(string v { List<Person> personList = new List< String selectFromMysqlDatabase = "S MySqlCommand command; MySqlDataReader reader; Person person; dbCONN.openDBConnection(); try { command = new MySqlCommand(sele
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
reader = command.ExecuteReader while (reader.Read()) { person = new Person(); person.Id = Convert.ToInt32 //.GetInt32(reader[0].T person.FirstName = reader[1 person.LastName = reader[2] person.Email = reader[3].To person.Gender = reader[4].T person.Language = reader[5] person.Country = reader[6] person.ImageName = reader[7 person.ImagePath = reader[8 person.ImageBlob = (byte[]) personList.Add(person);
} } catch (Exception err) { MessageBox.Show("Error " + err } finally { //reader.Close(); //command.Dispose(); dbCONN.closeDBConnection(); } return personList;
}
}
}
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #38 – How To Read Mysql Rows(Data) And Store Them In Array List
How To Populate (Bind) Datagridview From List Of Items In C# C# SOURCE CODE 1 2
? private void refreshDatagridView(string searchV {
3 4 5 6 7 8 9 10 11 12 13 14
dataGridView1.AutoSizeColumnsMode = DataGri dataGridView1.RowTemplate.Height = 45; BindingSource bsource = new BindingSource() PersonData pData = new PersonData(); bsource.DataSource = pData.PersonList(searc dataGridView1.DataSource = bsource;
}
//Fit Image In DataGridView Cell DataGridViewImageColumn dGVimageColumn = (D dGVimageColumn.ImageLayout = DataGridViewIm
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #39 – How To Populate (Bind) Datagridview From List Of Items
How To Move a Line(Selected Code) Up or Down in Visual Studio This involves moving the selected line of code up or down using keyboard shortcut. To do this you need to add appropriate plugin to your IDE (Visual Studio 2010). You can easily move lines up and down using MoveLine Extension. Download Link – https://marketplace.visualstudio.com/items? itemName=KevinAenmey.MoveLine
How to Move Selected Code Up or Down in Visual Studio – Homepage
To Download “Move Line Extension Using Visual Studio 2010” : Step 1. Go Tools
How to Move Selected Code Up or Down in Visual Studio â&#x20AC;&#x201C; Tools
Step 2. Choose Extension Manager.
How to Move Selected Code Up or Down in Visual Studio – Extension Manager
Step 3. From the left pane select “Online Gallery”.
How to Move Selected Code Up or Down in Visual Studio – Online gallery
Step 4. Type The name of the extension in the search box. In this Case “MoveLine”;
How to Move Selected Code Up or Down in Visual Studio â&#x20AC;&#x201C; Search MoveLine
Step 5. Then Click Download.
How to Move Selected Code Up or Down in Visual Studio â&#x20AC;&#x201C; Install MoveLine
Step 6. When The Download Finishes, restart your IDE.
How to Move Selected Code Up or Down in Visual Studio â&#x20AC;&#x201C; Restart IDE Visual Studio 2010
If you go back to extension manager, you will see that the extension has been added.
How to Move Selected Code Up or Down in Visual Studio – Installed
To move single line or selected block of code (Multiple Lines) use the keyboard shortcuts below. The default shortcut keys are as follows: Alt+Up Arrow – Moves a line up Alt+Down Arrow – Moves a line down To change the shortcut keys:
In the Visual Studio main menu go to Tools -> Options Expand Environment Select Keyboard In the Show commands containing box type Tools.MoveLineUp orTools.MoveLineDown In the Press shortcut keys box press the new shortcut keys Click Assign
VIDEO TUTORIAL C# AND MYSQL DATABASE TUTORIAL #4… #4…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #40 – How to Move a Line(Selected Code) Up or Down in Visual Studio
How To Check If Datagridview Row Is Selected Or Not In C# It’s good to check if a row is selected before performing a task on it. Failure to that results in unwanted errors.
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #41 – How To Check If Datagridview Row Is Selected Or Not
How To Get Datagridview Currently Selected Row Index On Row click C# Selected row has a unique index starting from 0.
VIDEO TUTORIAL C# AND MYSQL CRUD TUTORIAL #42 - H… H…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #42 – How To Get Datagridview Currently Selected Row Index On Row click
How To Display Selected Row From Datagridview To Textboxes In C# Selected row values are displayed in textboxes when you click on datagridview row.
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
? private void dataGridView1_CellClick(object sen { //Check If there is a row selected
if (dataGridView1.SelectedRows.Count > 0) { selectedRowIndex = e.RowIndex; // Selected Row //MessageBox.Show("Selected Row Index > DataGridViewRow selectedDGVRow = dataGr //Diplaying Selected DataGridView row d textBoxID.Text = selectedDGVRow.Cells[0 textBoxFirstName.Text = selectedDGVRow textBoxLastName.Text = selectedDGVRow.C textBoxEmail.Text = selectedDGVRow.Cell //Check if datagridview cell value matc if (selectedDGVRow.Cells[4].Value.ToStr { //Diplaying Selected DataGridView r radioButtonMale.Checked = true; } else
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
if (selectedDGVRow.Cells[4].Value.T { //Diplaying Selected DataGridVi radioButtonFemale.Checked = tru } if (selectedDGVRow.Cells[5].Value.ToStr { //Diplaying Selected DataGridView r checkBoxEnglish.Checked = true; } else if (selectedDGVRow.Cells[5].Value.T { //Diplaying Selected DataGridVi checkBoxArabic.Checked = true; } comboBoxCountry.Text = selectedDGVRow.C textBoxImageName.Text = selectedDGVRow textBoxImagePath.Text = selectedDGVRow //Diplaying Selected DataGridView row d byte[] imgB = (byte[])selectedDGVRow.Ce MemoryStream ms = new MemoryStream(imgB pictureBox1.Image = Image.FromStream(ms
} else {
}
}
//No Row Selected
How To Get Datagridview Currently Selected Row Index On Row click C
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #43 â&#x20AC;&#x201C; How To Display Selected Row From Datagridview Into Textboxes
How To Display Selected Row Image From Datagridview To Picturebox C# The image from datagridview is displayed in picturebox when you click on datagridview row.
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
? private void dataGridView1_CellClick(object sen { //Check If there is a row selected
if (dataGridView1.SelectedRows.Count > 0) { selectedRowIndex = e.RowIndex; // Selected Row //MessageBox.Show("Selected Row Index > DataGridViewRow selectedDGVRow = dataGr //Diplaying Selected DataGridView row d textBoxID.Text = selectedDGVRow.Cells[0 textBoxFirstName.Text = selectedDGVRow textBoxLastName.Text = selectedDGVRow.C
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
textBoxEmail.Text = selectedDGVRow.Cell //Check if datagridview cell value matc if (selectedDGVRow.Cells[4].Value.ToStr { //Diplaying Selected DataGridView r radioButtonMale.Checked = true; } else if (selectedDGVRow.Cells[4].Value.T { //Diplaying Selected DataGridVi radioButtonFemale.Checked = tru } if (selectedDGVRow.Cells[5].Value.ToStr { //Diplaying Selected DataGridView r checkBoxEnglish.Checked = true; } else if (selectedDGVRow.Cells[5].Value.T { //Diplaying Selected DataGridVi checkBoxArabic.Checked = true; } comboBoxCountry.Text = selectedDGVRow.C textBoxImageName.Text = selectedDGVRow textBoxImagePath.Text = selectedDGVRow //Diplaying Selected DataGridView row d byte[] imgB = (byte[])selectedDGVRow.Ce MemoryStream ms = new MemoryStream(imgB pictureBox1.Image = Image.FromStream(ms
} else {
}
}
//No Row Selected
How To Display Selected Row Image From Datagridview To Picturebox C
VIDEO TUTORIAL C# AND MYSQL CRUD TUTORIAL #44 - H… H…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #44 â&#x20AC;&#x201C; How To Display Selected Image From Datagridview Row To Picturebox
How To Display Selected Row Value From Datagridview To RadioButton C# Radio button gets selected when you click on datagridview row with the value that matches radio button value.
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
? private void dataGridView1_CellClick(object sen { //Check If there is a row selected
if (dataGridView1.SelectedRows.Count > 0) { selectedRowIndex = e.RowIndex; // Selected Row //MessageBox.Show("Selected Row Index > DataGridViewRow selectedDGVRow = dataGr //Diplaying Selected DataGridView row d textBoxID.Text = selectedDGVRow.Cells[0 textBoxFirstName.Text = selectedDGVRow textBoxLastName.Text = selectedDGVRow.C textBoxEmail.Text = selectedDGVRow.Cell //Check if datagridview cell value matc
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
if (selectedDGVRow.Cells[4].Value.ToStr { //Diplaying Selected DataGridView r radioButtonMale.Checked = true; } else if (selectedDGVRow.Cells[4].Value.T { //Diplaying Selected DataGridVi radioButtonFemale.Checked = tru } if (selectedDGVRow.Cells[5].Value.ToStr { //Diplaying Selected DataGridView r checkBoxEnglish.Checked = true; } else if (selectedDGVRow.Cells[5].Value.T { //Diplaying Selected DataGridVi checkBoxArabic.Checked = true; } comboBoxCountry.Text = selectedDGVRow.C textBoxImageName.Text = selectedDGVRow textBoxImagePath.Text = selectedDGVRow //Diplaying Selected DataGridView row d byte[] imgB = (byte[])selectedDGVRow.Ce MemoryStream ms = new MemoryStream(imgB pictureBox1.Image = Image.FromStream(ms
} else {
}
}
//No Row Selected
How To Display Selected Row Value From Datagridview To RadioButton C
VIDEO TUTORIAL C# AND MYSQL CRUD TUTORIAL #45 - H… H…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #45 â&#x20AC;&#x201C; How To Display Selected Row Value From Datagridview To RadioButton
How To Display Selected Row Value From Datagridview To CheckBox C# CheckBox gets checked when you click on datagridview row with the value that matches CheckBox value.
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
? private void dataGridView1_CellClick(object sen { //Check If there is a row selected
if (dataGridView1.SelectedRows.Count > 0) { selectedRowIndex = e.RowIndex; // Selected Row //MessageBox.Show("Selected Row Index > DataGridViewRow selectedDGVRow = dataGr //Diplaying Selected DataGridView row d textBoxID.Text = selectedDGVRow.Cells[0 textBoxFirstName.Text = selectedDGVRow textBoxLastName.Text = selectedDGVRow.C
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
textBoxEmail.Text = selectedDGVRow.Cell //Check if datagridview cell value matc if (selectedDGVRow.Cells[4].Value.ToStr { //Diplaying Selected DataGridView r radioButtonMale.Checked = true; } else if (selectedDGVRow.Cells[4].Value.T { //Diplaying Selected DataGridVi radioButtonFemale.Checked = tru } if (selectedDGVRow.Cells[5].Value.ToStr { //Diplaying Selected DataGridView r checkBoxEnglish.Checked = true; } else if (selectedDGVRow.Cells[5].Value.T { //Diplaying Selected DataGridVi checkBoxArabic.Checked = true; } comboBoxCountry.Text = selectedDGVRow.C textBoxImageName.Text = selectedDGVRow textBoxImagePath.Text = selectedDGVRow //Diplaying Selected DataGridView row d byte[] imgB = (byte[])selectedDGVRow.Ce MemoryStream ms = new MemoryStream(imgB pictureBox1.Image = Image.FromStream(ms
} else {
}
}
//No Row Selected
How To Display Selected Row Value From Datagridview To CheckBox C
VIDEO TUTORIAL C# AND MYSQL CRUD TUTORIAL #46 - H… H…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #46 â&#x20AC;&#x201C; How To Display Selected Row Value From Datagridview To CheckBox
How To Display Selected Row Value From Datagridview To ComboBox C# ComboBox displays the appropriate value when you click on datagridview row.
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
? private void dataGridView1_CellClick(object sen { //Check If there is a row selected
if (dataGridView1.SelectedRows.Count > 0) { selectedRowIndex = e.RowIndex; // Selected Row //MessageBox.Show("Selected Row Index > DataGridViewRow selectedDGVRow = dataGr //Diplaying Selected DataGridView row d textBoxID.Text = selectedDGVRow.Cells[0 textBoxFirstName.Text = selectedDGVRow textBoxLastName.Text = selectedDGVRow.C
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
textBoxEmail.Text = selectedDGVRow.Cell //Check if datagridview cell value matc if (selectedDGVRow.Cells[4].Value.ToStr { //Diplaying Selected DataGridView r radioButtonMale.Checked = true; } else if (selectedDGVRow.Cells[4].Value.T { //Diplaying Selected DataGridVi radioButtonFemale.Checked = tru } if (selectedDGVRow.Cells[5].Value.ToStr { //Diplaying Selected DataGridView r checkBoxEnglish.Checked = true; } else if (selectedDGVRow.Cells[5].Value.T { //Diplaying Selected DataGridVi checkBoxArabic.Checked = true; } comboBoxCountry.Text = selectedDGVRow.C textBoxImageName.Text = selectedDGVRow textBoxImagePath.Text = selectedDGVRow //Diplaying Selected DataGridView row d byte[] imgB = (byte[])selectedDGVRow.Ce MemoryStream ms = new MemoryStream(imgB pictureBox1.Image = Image.FromStream(ms
} else {
}
}
//No Row Selected
How To Display Selected Row Value From Datagridview To ComboBox C
VIDEO TUTORIAL C# AND MYSQL CRUD TUTORIAL #47 - H… H…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #47 â&#x20AC;&#x201C; How To Display Selected Row Value From Datagridview To ComboBox
How To clear Or Reset a combobox On Button Click In C# Clearing combobox on button click.
How To clear Or Reset a combobox On Button Click In C
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
? //Resetting/Clearing Textfields Function private void clearFields() { //Resetting/Clearing Textfields textBoxID.Text = String.Empty; textBoxFirstName.Text = String.Empty; textBoxLastName.Text = String.Empty; textBoxEmail.Text = String.Empty; textBoxImageName.Text = String.Empty; textBoxImagePath.Text = String.Empty; textBoxSearch.Text = String.Empty; //Clearing Picturebox pictureBox1.Image = null; //Clearing Combobox comboBoxCountry.Text = String.Empty; //Clearing/resetting Radiobuttons if (radioButtonMale.Checked) { radioButtonMale.Checked = false; } else if (radioButtonFemale.Checked) { radioButtonFemale.Checked = false; } //Clearing/resetting CheckBoxes if (checkBoxEnglish.Checked) { checkBoxEnglish.Checked = false; } else if (checkBoxArabic.Checked) { checkBoxArabic.Checked = false; }
37 38 39 40
//Refresh Datagridview After clearing field refreshDatagridView(""); }
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
How To clear Or Reset a combobox On Button Click In C
How To clear Or Reset Radio Button On Button Click In C# Resetting all radio buttons on button click.
How To clear Or Reset Radio Button On Button Click In C
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14
//Resetting/Clearing Textfields Function private void clearFields() { //Resetting/Clearing Textfields textBoxID.Text = String.Empty; textBoxFirstName.Text = String.Empty; textBoxLastName.Text = String.Empty; textBoxEmail.Text = String.Empty; textBoxImageName.Text = String.Empty; textBoxImagePath.Text = String.Empty; textBoxSearch.Text = String.Empty; //Clearing Picturebox pictureBox1.Image = null; //Clearing Combobox
?
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
comboBoxCountry.Text = String.Empty; //Clearing/resetting Radiobuttons if (radioButtonMale.Checked) { radioButtonMale.Checked = false; } else if (radioButtonFemale.Checked) { radioButtonFemale.Checked = false; } //Clearing/resetting CheckBoxes if (checkBoxEnglish.Checked) { checkBoxEnglish.Checked = false; } else if (checkBoxArabic.Checked) { checkBoxArabic.Checked = false; } //Refresh Datagridview After clearing field refreshDatagridView(""); }
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #49 â&#x20AC;&#x201C; How To clear Or Reset Radio Button On Button Click
How To clear Or Reset Check Box On Button Click In C# Unchecking all checkboxes on button click.
How To clear Or Reset Check Box On Button Click In C
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14
//Resetting/Clearing Textfields Function private void clearFields() { //Resetting/Clearing Textfields textBoxID.Text = String.Empty; textBoxFirstName.Text = String.Empty; textBoxLastName.Text = String.Empty; textBoxEmail.Text = String.Empty; textBoxImageName.Text = String.Empty; textBoxImagePath.Text = String.Empty; textBoxSearch.Text = String.Empty; //Clearing Picturebox pictureBox1.Image = null; //Clearing Combobox
?
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
comboBoxCountry.Text = String.Empty; //Clearing/resetting Radiobuttons if (radioButtonMale.Checked) { radioButtonMale.Checked = false; } else if (radioButtonFemale.Checked) { radioButtonFemale.Checked = false; } //Clearing/resetting CheckBoxes if (checkBoxEnglish.Checked) { checkBoxEnglish.Checked = false; } else if (checkBoxArabic.Checked) { checkBoxArabic.Checked = false; } //Refresh Datagridview After clearing field refreshDatagridView(""); }
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #51 â&#x20AC;&#x201C; How To clear Or Reset Text Boxes On Button Click
How To clear Or Reset Text Boxes On Button Click In C# Clearing all textbox values on button click. Empty values are assigned to Textbox in this scenario.
How To clear Or Reset Text Boxes On Button Click In C
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14
//Resetting/Clearing Textfields Function private void clearFields() { //Resetting/Clearing Textfields textBoxID.Text = String.Empty; textBoxFirstName.Text = String.Empty; textBoxLastName.Text = String.Empty; textBoxEmail.Text = String.Empty; textBoxImageName.Text = String.Empty; textBoxImagePath.Text = String.Empty; textBoxSearch.Text = String.Empty; //Clearing Picturebox pictureBox1.Image = null; //Clearing Combobox
?
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
comboBoxCountry.Text = String.Empty; //Clearing/resetting Radiobuttons if (radioButtonMale.Checked) { radioButtonMale.Checked = false; } else if (radioButtonFemale.Checked) { radioButtonFemale.Checked = false; } //Clearing/resetting CheckBoxes if (checkBoxEnglish.Checked) { checkBoxEnglish.Checked = false; } else if (checkBoxArabic.Checked) { checkBoxArabic.Checked = false; } //Refresh Datagridview After clearing field refreshDatagridView(""); }
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #51 â&#x20AC;&#x201C; How To clear Or Reset Text Boxes On Button Click
How To clear Or Reset Image On A Picturebox On Button Click In C# Clearing image from picture box on button click. This sets value of a picture box Image to null.
How To clear Or Reset Image On A Picturebox On Button Click In C
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14
//Resetting/Clearing Textfields Function private void clearFields() { //Resetting/Clearing Textfields textBoxID.Text = String.Empty; textBoxFirstName.Text = String.Empty; textBoxLastName.Text = String.Empty; textBoxEmail.Text = String.Empty; textBoxImageName.Text = String.Empty; textBoxImagePath.Text = String.Empty; textBoxSearch.Text = String.Empty; //Clearing Picturebox pictureBox1.Image = null; //Clearing Combobox
?
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
comboBoxCountry.Text = String.Empty; //Clearing/resetting Radiobuttons if (radioButtonMale.Checked) { radioButtonMale.Checked = false; } else if (radioButtonFemale.Checked) { radioButtonFemale.Checked = false; } //Clearing/resetting CheckBoxes if (checkBoxEnglish.Checked) { checkBoxEnglish.Checked = false; } else if (checkBoxArabic.Checked) { checkBoxArabic.Checked = false; } //Refresh Datagridview After clearing field refreshDatagridView(""); }
VIDEO TUTORIAL C# AND MYSQL CRUD TUTORIAL #52 - H… H…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #52 â&#x20AC;&#x201C; How To clear Or Reset Image On A Picturebox On Button Click
How To Make Only One Checkbox Checked At A Time C# Uncheck one checkbox when the other is checked.
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12
//Resetting/Clearing Textfields Function private void clearFields() { //Resetting/Clearing Textfields textBoxID.Text = String.Empty; textBoxFirstName.Text = String.Empty; textBoxLastName.Text = String.Empty; textBoxEmail.Text = String.Empty; textBoxImageName.Text = String.Empty; textBoxImagePath.Text = String.Empty; textBoxSearch.Text = String.Empty; //Clearing Picturebox
?
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
pictureBox1.Image = null; //Clearing Combobox comboBoxCountry.Text = String.Empty; //Clearing/resetting Radiobuttons if (radioButtonMale.Checked) { radioButtonMale.Checked = false; } else if (radioButtonFemale.Checked) { radioButtonFemale.Checked = false; } //Clearing/resetting CheckBoxes if (checkBoxEnglish.Checked) { checkBoxEnglish.Checked = false; } else if (checkBoxArabic.Checked) { checkBoxArabic.Checked = false; } //Refresh Datagridview After clearing field refreshDatagridView(""); }
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #53 – How To Make Only One Checkbox Checked At A Time
How To Disable Text Input [Editing] In TextBox In C# Disabling text input in textbox. Select textbox, go to properties and change “enabled” property value to false. This makes a textbox completely disabled. If you want to revert this change Enabled property value to “True”.
How To Disable Text Input Editing In TextBox In C â&#x20AC;&#x201C; Enable False
How To Disable Text Input Editing In TextBox In C
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #54 – How To Disable Text Input Or Editing In TextBox
How To Check If Input Fields Are Empty In C# Checking if input fields are empty before inserting their values to the database. If one of the field is blank you will not be able to insert data into the database.
C# SOURCE CODE 1 2 3 4 5 6
if (string.IsNullOrEmpty(textBoxFirstName.Text)? { //If there is one or more empty fields outpu MessageBox.Show("one or more empty fields. F }
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #55 â&#x20AC;&#x201C; How To Check If Input Fields Are Empty
How To Delete Data From Table In MySql Using C# Removing a row from Mysql database by clicking a button. Select the row you want to delete from the datagridview. So long as ID field has data you will be able to delete it from the database.
How To Delete Data From Table In MySql Using C
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14
? //Deleting data from mysql database private void button4_Click(object sender, Event {
//First Check if the textbox field is empty if (string.IsNullOrEmpty(textBoxID.Text)) { MessageBox.Show("Id Field Is Empty Firs } else { string deleteSQLQuery = "DELETE FROM `c
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
MySqlCommand deleteCommand; try {
//Open Database Connection dbCONN.openDBConnection(); deleteCommand = new MySqlCommand(de deleteCommand.Parameters.Add("@Id", //Check If The Data has been delete if (deleteCommand.ExecuteNonQuery() { MessageBox.Show("Data Deleted S }
}
}
} catch (Exception err) { MessageBox.Show("Err " + err); } finally { //close Database Connection dbCONN.closeDBConnection(); } //clear input fields after Deleting dat clearFields(); //Refresh datagridview after deleting d refreshDatagridView("");
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #56 â&#x20AC;&#x201C; How To Delete Data From MySql Table
How To Refresh Datagridview Rows After Change In MySql C# Reloading the rows after any database change.
How To Refresh Datagridview Rows After Change In MySql C
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14
//CALLING THIS FUNCTION REFRESHES DATAGRIDVIEW? private void refreshDatagridView(string { dataGridView1.AutoSizeColumnsMode = dataGridView1.RowTemplate.Height = BindingSource bsource = new Binding PersonData pData = new PersonData() bsource.DataSource = pData.PersonLi dataGridView1.DataSource = bsource; //Fit Image In DataGridView Cell DataGridViewImageColumn dGVimageCol dGVimageColumn.ImageLayout = DataGr
15
}
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #57 – How To Refresh Datagridview Rows After Change In MySql
How To Update Data From Table In MySql Using C# Updating Mysql database on button click. To update a row first select it from the datagridview, the input fields gets populated with the selected
row data. Edit the data then click update button.
How To Update Data From Table In MySql Using C
C# SOURCE CODE 1 2 3 4 5 6 7 8 9 10 11
? //Updating Mysql Database Row private void button3_Click(object sender, Event {
//First check if there is any empty field //Check //Check //Check //Check
If if if if
Input Fields Are Empty before in textboxes are empty Combobox Field is empty Picturebox Field is empty
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
if (string.IsNullOrEmpty(textBoxFirstName.T { //If there is one or more empty fields MessageBox.Show("one or more empty fiel } else { string updateSQLQuery = "UPDATE `csharp MySqlCommand updateCommand; //Check Which CheckBox Is Checked if (checkBoxEnglish.Checked) { languageCheckBox = "English"; } else if (checkBoxArabic.Checked) { languageCheckBox = "Arabic"; } //Check Which Button Is Checked if (radioButtonMale.Checked) { radioButtonValueGender = "Male"; } else if (radioButtonFemale.Checked) { radioButtonValueGender = "Femal } countryCombobox = comboBoxCountry.Selec MemoryStream ms = new MemoryStream(); pictureBox1.Image.Save(ms, pictureBox1
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
Byte[] img = ms.ToArray(); try {
//Open Connection dbCONN.openDBConnection(); updateCommand = new MySqlCommand(up updateCommand.Parameters.Add("@Firs updateCommand.Parameters.Add("@Last updateCommand.Parameters.Add("@Emai updateCommand.Parameters.Add("@Gend updateCommand.Parameters.Add("@Lang updateCommand.Parameters.Add("@Coun updateCommand.Parameters.Add("@Imag updateCommand.Parameters.Add("@Imag updateCommand.Parameters.Add("@Imag updateCommand.Parameters.Add("@Id", //check if data has been updated if (updateCommand.ExecuteNonQuery() { MessageBox.Show("Data Updated S }
}
} catch (Exception err) { MessageBox.Show("Error " + err); } finally { //close database connection dbCONN.closeDBConnection(); } //clear input fields after updating dat clearFields(); //Refresh datagridview to display updat refreshDatagridView("");
90
}
VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #58 – How To Update Data From Table In MySql
How To Search Data From MySql and Filter in datagridview Table In C# To search for a specific data enter the keywords in the search textbox. Datagridview displays data that matches your keyword on keypress.
How To Search Data From MySql and Filter in datagridview Table In C
C# SOURCE CODE 1 2 3 4 5
? private void textBox1_KeyUp(object sender, KeyEv { string val = textBoxSearch.Text; refreshDatagridView(val); }
VIDEO TUTORIAL C# AND MYSQL CRUD TUTORIAL #59 - H… H…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #59 – How To Search Data From MySql and Filter in datagridview Table
Fixing (GUI) Graphical User Interface VIDEO TUTORIAL C# AND MYSQL DATABASE CRUD TUTOR… TUTOR…
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #60 – Fixing (GUI) Graphical User Interface
Complete Video Tutorial C SHARP AND MYSQL DATABASE CRUD …
Watch later
Share
C# AND MYSQL DATABASE CRUD TUTORIAL #61 – Insert Update Search Delete And Display Data On DataGridView Using Visual Studio 2010 Complete Video Tutorial
Tags: C# Form Application, Database (Software Genre), localhost, mysql database, XAMPP
Published by admin
View all posts by admin
Prev C SHARP AND MYSQL DATABASE CRUD TUTORIAL 61 How To Insert
Next How To Download Mysql Connector For Visual Studio C Sharp Project
Update Search Delete And Display Data On DataGridView Complete Video Tutorial
Leave a Reply Your email address will not be published. Required fields are marked * Comment
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment. POST COMMENT
© Copyright 2020 – Maurice Muteti Allium Theme by TemplateLens ⋅ Powered by WordPress
PDFmyURL.com - convert URLs, web pages or even full websites to PDF online. Easy API for developers!