Working with DataBase


  • There are different methods to get connected to the database, but we are following the method given here.
  • Create an Window Application
  • Create Form in it
  • Click on the control BindingSource from the Tool Box and add it to the Form1

  • Create the database connectivity using the BindingSource object i.e. go to the property window of BindingSource1. From there select Data Source. From there click on to Add Project Data Source

  • From the resulting Data Source Configuration wizard select DataBase then click on to Next
  • From the resulting menu click on to New Connection

  • Select the Data Source as MS SQL Server (If it is not already selected then go to Change button and select MS SQL server)

  • In the Add Connection wizard, give the server name (ex: VISHWANATHA-PAI, You will get this name when we just highlight the cursor on the server icon on status bar in the bottom now it is USER i.e. \\USER-MSSQL Server) name of the server in which the Database is residing

  • Select Use Windows Authentication (by default it is selected)
  • Now using the select or enter database name option select the database to which you want to get connected to ( We have selected BCA). Then Click on to Test Connection. You must get a message Test Connection succeeded other wise it will display error message.

  • Then Click OK then again Click OK. Now click on to Next

  • Now here the save configuration wizard appears (The check box Yes, Save the connection as, should be selected) now click on to Next

  • Now You will get a Choose Your Database Object wizard. Here select the required objects (Tables, Views, Stored Procedures and Functions) Click on to Finish. Now a Data set named BCADataSet is created

  • Now add DataGrid control on to the form

  • Now, from the Property window of this, from Databinding option select Data Source

  • From here expand Other Data Source, then expand Project Data Source then expand BCADataSet then select the table whose data you want to be displayed in the Grid ( say BCAStdInfo)

  • Now BCAStdInfoBindingSource and BCAStdInfoAdapterTable are created which is shown:

  • Now go to Debug and Click on to start Debugging you will get the contents of BCAStdInfo table displayed in the datagrid

  • You can see the code for Form_load event the code is already generated
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'BCADataSet.BCAStdInfo' table. You can move, or remove it, as needed.
Me.BCAStdInfoTableAdapter.Fill (Me.BCADataSet.BCAStdInfo)
End Sub


Datasets<< Previous

Next>>Queries

Our aim is to provide information to the knowledge


comments powered by Disqus






Footer1