Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

A CRUD Form using SharpDevelop and PostgreSQL

, 21 Oct 2009
This article is a tutorial on how to create a CRUD (Create, Retrieve, Update and Delete) Form using SharpDevelop and PostgreSQL, implementing a BindingNavigator to explore the table used in the application.
CRUD_Music.zip
CRUD_Music
de
Npgsql.resources.dll
es
Npgsql.resources.dll
fi
Npgsql.resources.dll
fr
Npgsql.resources.dll
ja
Npgsql.resources.dll
Mono.Security.dll
Music.ex_
Npgsql.dll
zh-CN
Npgsql.resources.dll
CRUD_MusicSRC.zip
CRUD_MusicSRC
Music
Properties
/*
 * Created by SharpDevelop.
 * User: wancho
 * Date: 20/10/2009
 * Time: 14:37
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
namespace Music
{
	partial class MainForm
	{
		/// <summary>
		/// Designer variable used to keep track of non-visual components.
		/// </summary>
		private System.ComponentModel.IContainer components = null;
		
		/// <summary>
		/// Disposes resources used by the form.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing) {
				if (components != null) {
					components.Dispose();
				}
			}
			base.Dispose(disposing);
		}
		
		/// <summary>
		/// This method is required for Windows Forms designer support.
		/// Do not change the method contents inside the source code editor. The Forms designer might
		/// not be able to load this method if it was changed manually.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.t_artistID = new System.Windows.Forms.TextBox();
			this.t_name = new System.Windows.Forms.TextBox();
			this.bnavigator = new System.Windows.Forms.BindingNavigator(this.components);
			this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton();
			this.bsource = new System.Windows.Forms.BindingSource(this.components);
			this.mainDS = new System.Data.DataSet();
			this.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel();
			this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton();
			this.bindingNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton();
			this.bindingNavigatorMovePreviousItem = new System.Windows.Forms.ToolStripButton();
			this.bindingNavigatorSeparator = new System.Windows.Forms.ToolStripSeparator();
			this.bindingNavigatorPositionItem = new System.Windows.Forms.ToolStripTextBox();
			this.bindingNavigatorSeparator1 = new System.Windows.Forms.ToolStripSeparator();
			this.bindingNavigatorMoveNextItem = new System.Windows.Forms.ToolStripButton();
			this.bindingNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton();
			this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator();
			this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
			this.connection = new Npgsql.NpgsqlConnection();
			this.cmdInsert = new Npgsql.NpgsqlCommand();
			this.adapter = new Npgsql.NpgsqlDataAdapter();
			this.cmdDelete = new Npgsql.NpgsqlCommand();
			this.cmdSelect = new Npgsql.NpgsqlCommand();
			this.cmdUpdate = new Npgsql.NpgsqlCommand();
			((System.ComponentModel.ISupportInitialize)(this.bnavigator)).BeginInit();
			this.bnavigator.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.bsource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.mainDS)).BeginInit();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(31, 41);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(76, 17);
			this.label1.TabIndex = 0;
			this.label1.Text = "Artist ID";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(31, 76);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(78, 20);
			this.label2.TabIndex = 1;
			this.label2.Text = "Artist Name";
			// 
			// t_artistID
			// 
			this.t_artistID.Location = new System.Drawing.Point(104, 38);
			this.t_artistID.Name = "t_artistID";
			this.t_artistID.Size = new System.Drawing.Size(92, 20);
			this.t_artistID.TabIndex = 3;
			// 
			// t_name
			// 
			this.t_name.Location = new System.Drawing.Point(104, 73);
			this.t_name.Name = "t_name";
			this.t_name.Size = new System.Drawing.Size(247, 20);
			this.t_name.TabIndex = 4;
			// 
			// bnavigator
			// 
			this.bnavigator.AddNewItem = this.bindingNavigatorAddNewItem;
			this.bnavigator.BindingSource = this.bsource;
			this.bnavigator.CountItem = this.bindingNavigatorCountItem;
			this.bnavigator.DeleteItem = this.bindingNavigatorDeleteItem;
			this.bnavigator.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
									this.bindingNavigatorMoveFirstItem,
									this.bindingNavigatorMovePreviousItem,
									this.bindingNavigatorSeparator,
									this.bindingNavigatorPositionItem,
									this.bindingNavigatorCountItem,
									this.bindingNavigatorSeparator1,
									this.bindingNavigatorMoveNextItem,
									this.bindingNavigatorMoveLastItem,
									this.bindingNavigatorSeparator2,
									this.bindingNavigatorAddNewItem,
									this.bindingNavigatorDeleteItem,
									this.toolStripButton1});
			this.bnavigator.Location = new System.Drawing.Point(0, 0);
			this.bnavigator.MoveFirstItem = this.bindingNavigatorMoveFirstItem;
			this.bnavigator.MoveLastItem = this.bindingNavigatorMoveLastItem;
			this.bnavigator.MoveNextItem = this.bindingNavigatorMoveNextItem;
			this.bnavigator.MovePreviousItem = this.bindingNavigatorMovePreviousItem;
			this.bnavigator.Name = "bnavigator";
			this.bnavigator.PositionItem = this.bindingNavigatorPositionItem;
			this.bnavigator.Size = new System.Drawing.Size(412, 25);
			this.bnavigator.TabIndex = 6;
			this.bnavigator.Text = "bindingNavigator1";
			// 
			// bindingNavigatorAddNewItem
			// 
			this.bindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.bindingNavigatorAddNewItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorAddNewItem.Image")));
			this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem";
			this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true;
			this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(23, 22);
			this.bindingNavigatorAddNewItem.Text = "Add new";
			// 
			// bsource
			// 
			this.bsource.DataSource = this.mainDS;
			this.bsource.Position = 0;
			// 
			// mainDS
			// 
			this.mainDS.DataSetName = "NewDataSet";
			// 
			// bindingNavigatorCountItem
			// 
			this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem";
			this.bindingNavigatorCountItem.Size = new System.Drawing.Size(36, 22);
			this.bindingNavigatorCountItem.Text = "of {0}";
			this.bindingNavigatorCountItem.ToolTipText = "Total number of items";
			// 
			// bindingNavigatorDeleteItem
			// 
			this.bindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.bindingNavigatorDeleteItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorDeleteItem.Image")));
			this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem";
			this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true;
			this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(23, 22);
			this.bindingNavigatorDeleteItem.Text = "Delete";
			// 
			// bindingNavigatorMoveFirstItem
			// 
			this.bindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.bindingNavigatorMoveFirstItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveFirstItem.Image")));
			this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem";
			this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true;
			this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(23, 22);
			this.bindingNavigatorMoveFirstItem.Text = "Move first";
			// 
			// bindingNavigatorMovePreviousItem
			// 
			this.bindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.bindingNavigatorMovePreviousItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMovePreviousItem.Image")));
			this.bindingNavigatorMovePreviousItem.Name = "bindingNavigatorMovePreviousItem";
			this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true;
			this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(23, 22);
			this.bindingNavigatorMovePreviousItem.Text = "Move previous";
			// 
			// bindingNavigatorSeparator
			// 
			this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator";
			this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 25);
			// 
			// bindingNavigatorPositionItem
			// 
			this.bindingNavigatorPositionItem.AccessibleName = "Position";
			this.bindingNavigatorPositionItem.AutoSize = false;
			this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem";
			this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 21);
			this.bindingNavigatorPositionItem.Text = "1";
			this.bindingNavigatorPositionItem.ToolTipText = "Current position";
			// 
			// bindingNavigatorSeparator1
			// 
			this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator1";
			this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 25);
			// 
			// bindingNavigatorMoveNextItem
			// 
			this.bindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.bindingNavigatorMoveNextItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveNextItem.Image")));
			this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem";
			this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true;
			this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(23, 22);
			this.bindingNavigatorMoveNextItem.Text = "Move next";
			// 
			// bindingNavigatorMoveLastItem
			// 
			this.bindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.bindingNavigatorMoveLastItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveLastItem.Image")));
			this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem";
			this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true;
			this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(23, 22);
			this.bindingNavigatorMoveLastItem.Text = "Move last";
			// 
			// bindingNavigatorSeparator2
			// 
			this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator2";
			this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 25);
			// 
			// toolStripButton1
			// 
			this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
			this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
			this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButton1.Name = "toolStripButton1";
			this.toolStripButton1.Size = new System.Drawing.Size(23, 22);
			this.toolStripButton1.Text = "toolStripButton1";
			this.toolStripButton1.Click += new System.EventHandler(this.ToolStripButton1Click);
			// 
			// connection
			// 
			this.connection.ConnectionString = "HOST=localhost;DATABASE=music;USER ID=postgres;PASSWORD=admin";
			// 
			// cmdInsert
			// 
			this.cmdInsert.CommandText = "INSERT INTO artists (artistID,name) VALUES ( :p_artistID , :p_name)";
			this.cmdInsert.Connection = this.connection;
			this.cmdInsert.Transaction = null;
			// 
			// adapter
			// 
			this.adapter.DeleteCommand = this.cmdDelete;
			this.adapter.InsertCommand = this.cmdInsert;
			this.adapter.SelectCommand = this.cmdSelect;
			this.adapter.UpdateCommand = this.cmdUpdate;
			// 
			// cmdDelete
			// 
			this.cmdDelete.CommandText = "DELETE FROM artists WHERE artistID=:p_artistID";
			this.cmdDelete.Connection = this.connection;
			this.cmdDelete.Transaction = null;
			// 
			// cmdSelect
			// 
			this.cmdSelect.CommandText = "SELECT artistID,name FROM artists";
			this.cmdSelect.Connection = this.connection;
			this.cmdSelect.Transaction = null;
			// 
			// cmdUpdate
			// 
			this.cmdUpdate.CommandText = "UPDATE artists SET name=:p_name WHERE artistID=:p_artistID";
			this.cmdUpdate.Connection = this.connection;
			this.cmdUpdate.Transaction = null;
			// 
			// MainForm
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.ClientSize = new System.Drawing.Size(412, 169);
			this.Controls.Add(this.bnavigator);
			this.Controls.Add(this.t_name);
			this.Controls.Add(this.t_artistID);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Name = "MainForm";
			this.Text = "Music";
			this.Load += new System.EventHandler(this.MainFormLoad);
			((System.ComponentModel.ISupportInitialize)(this.bnavigator)).EndInit();
			this.bnavigator.ResumeLayout(false);
			this.bnavigator.PerformLayout();
			((System.ComponentModel.ISupportInitialize)(this.bsource)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.mainDS)).EndInit();
			this.ResumeLayout(false);
			this.PerformLayout();
		}
		private System.Windows.Forms.ToolStripButton toolStripButton1;
		private System.Windows.Forms.TextBox t_artistID;
		private System.Windows.Forms.TextBox t_name;
		private System.Data.DataSet mainDS;
		private System.Windows.Forms.BindingSource bsource;
		private Npgsql.NpgsqlCommand cmdSelect;
		private Npgsql.NpgsqlCommand cmdDelete;
		private Npgsql.NpgsqlCommand cmdUpdate;
		private Npgsql.NpgsqlDataAdapter adapter;
		private Npgsql.NpgsqlCommand cmdInsert;
		private Npgsql.NpgsqlConnection connection;
		private System.Windows.Forms.BindingNavigator bnavigator;
		private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator2;
		private System.Windows.Forms.ToolStripButton bindingNavigatorMoveLastItem;
		private System.Windows.Forms.ToolStripButton bindingNavigatorMoveNextItem;
		private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator1;
		private System.Windows.Forms.ToolStripTextBox bindingNavigatorPositionItem;
		private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator;
		private System.Windows.Forms.ToolStripButton bindingNavigatorMovePreviousItem;
		private System.Windows.Forms.ToolStripButton bindingNavigatorMoveFirstItem;
		private System.Windows.Forms.ToolStripButton bindingNavigatorDeleteItem;
		private System.Windows.Forms.ToolStripLabel bindingNavigatorCountItem;
		private System.Windows.Forms.ToolStripButton bindingNavigatorAddNewItem;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label1;
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Juan Fajardo
Software Developer TuXSTONe Technologies
Colombia Colombia
Colombian, TuXSTONe Technologies developer,
Software Developer since 1996,
Computers Engineer and Network Software Developing Specialist since 2003.
 
Experience in developing software using PHP,C, C#, Java, Perl.

| Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 21 Oct 2009
Article Copyright 2009 by Juan Fajardo
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid