How to use C# Windows Forms with Firebird and Object Orientation?

Asked

Viewed 640 times

1

I recently learned a little object orientation and c#. But I am trying to create an application that is developed in c# windows Forms, with database Firebird and object-oriented. But what’s the right way to do this? How do I connect my database to my application and how do I make it interact with the visual studio interface? I’ve also seen that it is possible to use App.Config as in the sql, but how do I do it?


For example, currently I have the repostoring of a class and within it create events like add, change and etc, usually I do so:

public void Adicionar(Pais pais)
{
    string sql = "INSERT INTO PAIS (PAINOME) VALUES('" + pais.PaiNome+ ")";

    Conexao.Active(true);
    FbCommand cmd = new FbCommand(sql, Conexao.fbCnn);
    cmd.ExecuteNonQuery();
    Conexao.Active(false);
}

That way every time I make some changes in the classes I have to change in all the repositories, for example, if I add a new field to the country I would have to change in all the sql strings by adding the new field. Is this the right way to do it? I can make it more automatic or not?

Thank you!

1 answer

-1


Legal your interest in programming.

But my tip is, try to do things one step at a time. Learn how to connect through C#, then learn how to use Windows Forms, then try connecting to Firebird.

I understand that the will to learn and do something of your own is great. But things happen in sequence.

Below are some tutorials in Portuguese, nothing hard to find on Google, and nothing less than what you will find here, your question being so generic.

http://www.devmedia.com.br/conectando-em-uma-base-de-dados-firebird-com-c/11938

http://www.macoratti.net/08/09/c_fbd1.htm

https://stackoverflow.com/questions/4014097/how-to-connect-and-use-firebird-db-embedded-server-with-visual-c-sharp-2010

  • Thanks for the tips and help!

  • Give one up then, if you considered as answer ;)

  • I’m new here and I don’t even know much! It was bad.

  • Just click on the icon next to my answer, saying it’s the right answer. Hug

Browser other questions tagged

You are not signed in. Login or sign up in order to post.