A crud form using sharpdevelop and postgresql – codeproject

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. Data recovery pc We will be using SharpDevelop 3.1, PostgreSQL 8.3 for Windows, and of course Npgsql so we can connect our application to the PostgreSQL Server. Data recovery easeus Background

BindingNavigator is a very useful control, it can be used in a C# form to show and edit data from a SQL source or just a data repository (XML, text files); however, most tutorials and samples are oriented to Visual Studio and database servers as MS SQL Server. Top 10 data recovery software With this tutorial, you will be able to build a useful form with a BindingNavigator, fully functional, but using the exceptional IDE SharpDevelop. Database oracle What do you need?

You will need .NET Framework installed (of course), SharpDevelop 3.1 (at the time of writing this article, the stable and latest release of SharpDevelop is 3.1), PostgreSQL 8.3 for Windows, and a good database admin tool to create and edit the database schema: pgAdmin 3 is a good choice, and it comes included with the Postgres installer; you will need the Npgsql, but it’s included in the Zip file linked in this article.

We will create a small database with a single table.


Data recovery services reviews Our table is called artists and will be used to store our main data set. Database 12c new features You will need to first create the database in PgAdmin; in our example, our database will be called music.

Now you should insert a couple of rows in the table, so you can eventually test the ability to edit data in our form. Database lyrics You can insert data using the PgAdmin data editor:

Using SharpDevelop, create a new solution, choose “Window Application” under the C# category; in our example, the solution name will be Music. Database 360 As we will be using PostgreSQL as our database server, we must add the Npgsql library to our references.

• In the .NET Assembly Browser tab, look for the Npgsql DLL files ( npgsql.dll and Mono.Security.dll); you can use the files inside the Zip file included with this article, or you can download the latest Npgsql binary available at the Npgsql website.

Now go to the form design window. Database architect salary Here, we are going to add our main components that will be used in the form. Database administrator job description Select and add two Label components, and add two TextBoxes; in our example, the name of our TextBoxes will be t_artistID and t_name.

We must set the component properties so that our binding navigator can use our binding source to explore our data, our binding source can get the data from the dataset, the dataset can be filled using the data adapter, the adapter uses our commands to insert, update, delete, and select, and then our commands can access the database using our connection. Data recovery app Pretty simple, uh?, OK, let’s start:

• On the connection, set the ConnectionString property to something like: HOST=localhost;DATABASE=music;USER ID=postgres;PASSWORD=admin (change this according to your server host, database, and user info).

• On the adapter, set the properties DeleteCommand, InsertCommand, SelectCommand, and UpdateCommand to their respective components, cmdDelete, cmdInsert, cmdSelect, and cmdUpdate.

• Now we must edit the properties for the commands, each one according to the function; on the four components, we must set the Connection property to use our connection component.

• On cmdInsert, set the Command Text property to: INSERT INTO artists (artistID,name) VALUES (:p_artistID , :p_name). R database connection Note: The : p_ xxx are the parameters used by the SQL commands; soon, we will bind these parameters to the TextBox elements in the form.

OK, that’s it, our properties are set. Database weak entity Now we must enter the code that will be used to bind our controls, double click over the form to open the MainFormLoad Event Handler, then we must write our small fragment of code.

Please note that on every command, we must set the parameters used by this command, and take special care of setting their respective DBTypes according to the data type in the database.

That’s it, we’re almost done; the only thing that we must add is a Save button, because our Insert, Delete, and Update operations won’t be sent to the database if we don’t save our current data.

using the Image property of the newly created button. Data recovery vancouver Now, double click over the new button to open the button event handler: void ToolStripButton1Click( object sender, EventArgs e)

banner