steps to get start building c# applications - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

steps to get start building c# applications

alkahlialkahli Posts: 2Member
I was programming using other languages, I want to shift to c#,now I have a database project, pls send me the steps to get start

best reguards
alkahli

Comments

  • Yepper65Yepper65 Posts: 29Member
    : I was programming using other languages, I want to shift to c#,now I have a database project, pls send me the steps to get start
    :
    : best reguards
    : alkahli
    :
    Hi,

    Let's say you have C#.Net standard edition installed and the Microsoft Visual Studio .Net icon on your desktop.
    Further you have a Access database that i will call "Customers"in this example,but it can be any name.

    When you double-click on the Visual Studio .Net icon the IDE opens and you start with a new project, select the Windows Application icon because that's the application you want to build, and give the application the name you want (Let's say you call it "MySoftware", but as location of this new application you fill in C:Program Files, so the code you are going to create comes in the new folder: MySoftware in your Program Files folder.

    After clicking on the OK button a folder with the name "MySoftware" is created in your Program Files and you get an empty form called "Form1" in your IDE (Working enviroment), and see that the projectname MySoftware is displayed in the Header of the IDE, and also the name of the Form your are working on is displayed (Form1.cs).

    Minimize the IDE and put the "customers" database in the "MySoftware" folder in the Program Folder, but put it in a new folder you create in your "MySoftware" folder, that you call "DB" ("When you open the "MySoftware" folder you see that Visual Studio has created a lot of files in this folder, that files are representing your project).

    When you have done this you maximize you IDE window again to start working.

    Go to the Menu Item "View" and select "Server Explorer, and select the + symbol on the right, you get a screen called "Data Link Properties" with four tabs.
    Select the Tab on the left ("I have a Dutch version but i think it's called Services or something like that"), and you see a list of MicrosoftISAM 1.1 OLE DB Provider, MicrosoftJet 4.0 OLE DB Provider etc, select the MicrosoftJet 4.0 DB provider and push the Next Button.
    ("Later on you can choose and test other connections")
    You will be directed to the Connection Tab where you have to select the name of the Database by pointing at the C:Program FilesMySoftwareDBcustomers.mdb file, or you type in this adress.
    Under .2 on the tab page you see Admin and an inactive Password field, with Empty Password selected.
    Select the Test Connection button and you see that the connection with the DB succeeds.
    Click on OK to close the Data Link properties screen, and you see on the left that a connection with your Access database is established.
    When you expand this connecion you get a vieuw with all the tables, views and Stored procedures from this DB.

    Now you go to the menu Item View again and select the Toolbox, go to the Data Tab, and drag the OleDBDataAdapter to your Form1, an other screen will be opened to configure your Data Adapter.
    You see that the connection that you can use ("The one you have created before") is selected, click on the Next Button and you get a screen where you see the Use of SQL statements selected, this is Ok, so click again on the Next Button.
    You get to the screen now where you can generate the SQL statements, on this screen you have two buttons, one with Advanced Options with, when you click on this the command to generate the Insert, update and Delete Statements, and the Use optimistic concurency selected, close this screen, and click on the Query Builder Button, and there you see the tables of your customers DB.
    Let's assume this DB has one table called Customer, and that's the table you Add to the Query Builder.
    Select "All Collums", and Click on the OK button", the screen of the Query Builder will close.
    Click then on the Next Button and you get a confirmation that the "oleDBDataAdapter1" was configured succesfully, and click on the Finish Button.
    You get a screen that's asking you if you want to include your password, and select No, so your Password won't be in the code included.
    Now go to the Menu Item "Data" and select the Preview Data option, when you click on the Fill Dataset button on the screen you get, you should see some data from your customer DB.
    Close this screen and select under the same Menu Item "Data" the "Generate Dataset" option.
    You see that the new option is selected and that the dataset is going to be named "Dataset1"by default, this is ok for this moment, but you can give it any name, you see also that the table customers is selected with the name of the Data adapter behind it (oleDBDataAdapter1). Click on OK, and you see that there are three items created below your Form1 ( The oleDBDataAdapter1, the oleDbConnection1 and the dataSet11).
    The connection with you DB is established, you get a dataSet, so now you have to add a button and a DataGrid to your form.
    Go to the Toolbox again, select the Windows Forms tab, drag a button to the form, and drag a DataGrid to the form, position them so the DataGrid can display enough rows from your customer DB.
    Select the DataGrid and rightclick your mouse, you get a menu and select the Properties option at the bottom, the properties of the DataGrid will be displayed. Make sure you click the A to Z symbol at the top and go to the DataSource option, select the arrow and select dataSet11.customers. When you have done this you see the rows of your table displayed, and the names of the "fields" in the table displayed, but no actual data.
    Select the button, rightclick the properties again and give this button under the Text option the properties "Fill", and the text on the button will change from button 1 to Fill.
    Select the Lightning symbol on the top of the properties from this button and on top you see the option Click, type here Fill_Click and hit the Enter return on your keyboard.
    You are directed to the code behind the form and you see that a Method called Fill_Click is created.
    Now put the following code between the {}.

    private void Fill_Click(object sender, System.EventArgs e)
    {
    this.oleDbConnection1.Open();// Opens the connection
    this.oleDbDataAdapter1.Fill(dataSet11); Fills the DataSet
    this.oleDbConnection1.Close();// Closes the connection
    }

    *Note "The code above is not complete because it lacks error handling but i wanted to keep this example simple".

    *Note: "You can also use the DataForm wizzard and get all the Insert, Update and Delete commands working"

    After this push the F5 button on your keyboard, the application is being debugd,and you get the Form1 on your screen, push the Fill button and you see the data from your Db displayed.


  • alkahlialkahli Posts: 2Member
    : : I was programming using other languages, I want to shift to c#,now I have a database project, pls send me the steps to get start
    : :
    : : best reguards
    : : alkahli
    : :
    : Hi,
    :
    : Let's say you have C#.Net standard edition installed and the Microsoft Visual Studio .Net icon on your desktop.
    : Further you have a Access database that i will call "Customers"in this example,but it can be any name.
    :
    : When you double-click on the Visual Studio .Net icon the IDE opens and you start with a new project, select the Windows Application icon because that's the application you want to build, and give the application the name you want (Let's say you call it "MySoftware", but as location of this new application you fill in C:Program Files, so the code you are going to create comes in the new folder: MySoftware in your Program Files folder.
    :
    : After clicking on the OK button a folder with the name "MySoftware" is created in your Program Files and you get an empty form called "Form1" in your IDE (Working enviroment), and see that the projectname MySoftware is displayed in the Header of the IDE, and also the name of the Form your are working on is displayed (Form1.cs).
    :
    : Minimize the IDE and put the "customers" database in the "MySoftware" folder in the Program Folder, but put it in a new folder you create in your "MySoftware" folder, that you call "DB" ("When you open the "MySoftware" folder you see that Visual Studio has created a lot of files in this folder, that files are representing your project).
    :
    : When you have done this you maximize you IDE window again to start working.
    :
    : Go to the Menu Item "View" and select "Server Explorer, and select the + symbol on the right, you get a screen called "Data Link Properties" with four tabs.
    : Select the Tab on the left ("I have a Dutch version but i think it's called Services or something like that"), and you see a list of MicrosoftISAM 1.1 OLE DB Provider, MicrosoftJet 4.0 OLE DB Provider etc, select the MicrosoftJet 4.0 DB provider and push the Next Button.
    : ("Later on you can choose and test other connections")
    : You will be directed to the Connection Tab where you have to select the name of the Database by pointing at the C:Program FilesMySoftwareDBcustomers.mdb file, or you type in this adress.
    : Under .2 on the tab page you see Admin and an inactive Password field, with Empty Password selected.
    : Select the Test Connection button and you see that the connection with the DB succeeds.
    : Click on OK to close the Data Link properties screen, and you see on the left that a connection with your Access database is established.
    : When you expand this connecion you get a vieuw with all the tables, views and Stored procedures from this DB.
    :
    : Now you go to the menu Item View again and select the Toolbox, go to the Data Tab, and drag the OleDBDataAdapter to your Form1, an other screen will be opened to configure your Data Adapter.
    : You see that the connection that you can use ("The one you have created before") is selected, click on the Next Button and you get a screen where you see the Use of SQL statements selected, this is Ok, so click again on the Next Button.
    : You get to the screen now where you can generate the SQL statements, on this screen you have two buttons, one with Advanced Options with, when you click on this the command to generate the Insert, update and Delete Statements, and the Use optimistic concurency selected, close this screen, and click on the Query Builder Button, and there you see the tables of your customers DB.
    : Let's assume this DB has one table called Customer, and that's the table you Add to the Query Builder.
    : Select "All Collums", and Click on the OK button", the screen of the Query Builder will close.
    : Click then on the Next Button and you get a confirmation that the "oleDBDataAdapter1" was configured succesfully, and click on the Finish Button.
    : You get a screen that's asking you if you want to include your password, and select No, so your Password won't be in the code included.
    : Now go to the Menu Item "Data" and select the Preview Data option, when you click on the Fill Dataset button on the screen you get, you should see some data from your customer DB.
    : Close this screen and select under the same Menu Item "Data" the "Generate Dataset" option.
    : You see that the new option is selected and that the dataset is going to be named "Dataset1"by default, this is ok for this moment, but you can give it any name, you see also that the table customers is selected with the name of the Data adapter behind it (oleDBDataAdapter1). Click on OK, and you see that there are three items created below your Form1 ( The oleDBDataAdapter1, the oleDbConnection1 and the dataSet11).
    : The connection with you DB is established, you get a dataSet, so now you have to add a button and a DataGrid to your form.
    : Go to the Toolbox again, select the Windows Forms tab, drag a button to the form, and drag a DataGrid to the form, position them so the DataGrid can display enough rows from your customer DB.
    : Select the DataGrid and rightclick your mouse, you get a menu and select the Properties option at the bottom, the properties of the DataGrid will be displayed. Make sure you click the A to Z symbol at the top and go to the DataSource option, select the arrow and select dataSet11.customers. When you have done this you see the rows of your table displayed, and the names of the "fields" in the table displayed, but no actual data.
    : Select the button, rightclick the properties again and give this button under the Text option the properties "Fill", and the text on the button will change from button 1 to Fill.
    : Select the Lightning symbol on the top of the properties from this button and on top you see the option Click, type here Fill_Click and hit the Enter return on your keyboard.
    : You are directed to the code behind the form and you see that a Method called Fill_Click is created.
    : Now put the following code between the {}.
    :
    : private void Fill_Click(object sender, System.EventArgs e)
    : {
    : this.oleDbConnection1.Open();// Opens the connection
    : this.oleDbDataAdapter1.Fill(dataSet11); Fills the DataSet
    : this.oleDbConnection1.Close();// Closes the connection
    : }
    :
    : *Note "The code above is not complete because it lacks error handling but i wanted to keep this example simple".
    :
    : *Note: "You can also use the DataForm wizzard and get all the Insert, Update and Delete commands working"
    :
    : After this push the F5 button on your keyboard, the application is being debugd,and you get the Form1 on your screen, push the Fill button and you see the data from your Db displayed.
    :
    :
    : Hi,
    Thanks alot for your usfull information and instructions you mentioned, and thanks again for being patient in writing this replyment. I shall try this and I may write agin to you for further steps if you allow me. Thanks again and again.
    best regards

Sign In or Register to comment.