Performing Data Manipulations using Disconnected Model

Ratings:
(4)
Views:467
Banner-Img
  • Share this blog:

 

Performing Data Manipulations using Disconnected Model:

Inserting the record using a disconnected model

UntitledOpen SQL SERVER

Create

Take a new WINFORM and design like  

sql server  

// Code for button1_click

Imports System.Data

Imports System.Data.SqlClient

In form

‘Form declarations

Dim cn as SqlConnection

Dim da as SqlDataAdapter

Dim cmb as SqlCommandBuilder

Dim ds as DataSet  

// Form_Load

Cn = New SqlConnection (“user id = sa; password = 123; database = northwind; data source = sekhar”)

da = New SqlDataAdapter (“Select * from dept270”, cn)

cmb = New SqlCommandBuilder (da)

ds = New DataSet

da.Fill (ds, “dept270”)

ds.Tables (“Dept270”).Constrints.Add (“deptno_Pk”,

ds.tables (“Dept270”).Columns (“dept no”), True)

// Code for Add Department (button_click)

Try

Dim row as DataRow

row = ds.Tables (“Dept270”).NewRow

row (“dept no”) = txt Deptno.Text

row (“dept name”) = txt Dname.Text

row (“Loc”) = txtLoc.Text

ds.Tables (“Dept270”).Rows.Add (row da.update (ds.Tables (“Dept270”))

If MessageBox.Show (“Department added do you want to add another department”, Me.Text, MessageBoxbuttons.YesNo, MessageBoxIcon Question) = Windows.Forms.DIalogResult.Yes Then

txtDeptno.Clear ()

txtDname.Clear ()

txtLoc.Clear ()

txtDeptno.Clear ()

Else

End

End if

Catch ex as Exception

MessageBox.Show (ex.Message, “Error”)

End try

Untitled Execute

Performing updations and deletions using ADD.Net disconnected model  

 

  sql server

If you want to enrich your career and become a professional in SQL Server, then visit Tekslate - a global online training platform: "SQL Server Training"   This course will help you to achieve excellence in this domain

Imports System.Data

Imports System.Data.SqlClient

‘Form declarations

Dim cn as SqlConnection

Dim da as SqlDataAdapter

Dim cmb as SqlCommandBuilder

Dim ds as DataSet

Dim row as DataRow

Form_Load

Cn = New SqlConnection (“user id = sa; password = 123; database = northwind; data source = sekhar”)

da = New SqlDataAdapter (“Select * from dept270”, cn)

cmb = New SqlCommandBuilder (da)

ds = New DataSet

da.Fill (ds, “dept270”)

ds.Tables (“Dept270”).Constrints.Add (“deptno_Pk”, ds.tables (“Dept270”).Columns (“dept no”), True)

// Code for Add Department (button_click)

‘Search (button_click)

Dim dno as Integer

Dno = Val (txtDeptno.Text)

If ds.tables (“dept270”).Rows.Contains (dno) = True

Then

Row = ds.Tables (“dept270”).Rows.Find (dno)

txtDname.Text = row (“Dname”)

txtLoc.Text = row (“Loc”)

Else

MessageBox.Show (“Department not found”, “Error”)

‘Update (button_click)

Try

row (“dname”) = txtDname.Text

row (“loc”) = txtloc.Text

row.EndEdit ()

da.Update (ds.Tables (“dept270”))

MessageBox.Show (“Record updated”, Me.Text)

Catch ex as Exception

MessageBox.Show (ex.Message, “Error”)

End try

// ‘Delete (button_click)

Try

row.Delete ()

da.Update (ds.Tables (“dept270”))

MessageBox.Show (“Record Deleted”, Me.Text)

txtDeptno.Clear ()

txtDname.Clear ()

txtLoc.Clear ()

txtDeptno.Clear ()

Catch ex as Exception

MessageBox.Show (ex.Message, “Error”)

End try

‘Close (button_click)

End

Concepts to remember (Add.Net disconnected model)

  • Projecting the data (all rows & navigations)
  • Various search methods supported
  • Relationships between tables
  • Data manipulations

 COM Interoperability Model:

Whenever a COM component is used within a .Net application or if a .Net assembly is used from a COM type application then it is said to be supporting COM interoperability.  

Using COM Components from .Net application sql server model  

Whenever a .Net application uses the definition of COM component then a request will be given to the CLR where the CLR identifies the request type and defines Runtime Callable Wrapper (RCW) Once RCW is defined then it sends a request for the COM server where the COM component is identified based on its GUID (Global Unique identifier) and the component type library definitions will be returned to the RCW. Once RCW collects the data then it creates an interoperable COM which is an assembly once the assembly is created then the .Net application will consume that assembly and provides the output.

Get In-Depth Knowledge on SQL Server Click on Here:

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox