Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
how to use command builder,and without command builder to sve data in back end tabel
Posted
Comments
_Amy 27-Jul-13 1:46am    
Don't be so lazy. Just try to utilize google services. Check Command Builder in c#[^].

1 solution

Belowing code will help you..........




// Learn more about F# at http://fsharp.net
//-------------- Importing Namespace
open System
open System.Windows.Forms
open System.Drawing
open System.Data.SqlClient
open System.Data

//------------- Connection String
let constr = @"Data Source=SERVER_NAME;Initial Catalog=STUDENT;Integrated Security=True"

//------------- Creating Form and User Controls
let frm = new Form()
let dg = new DataGrid(Top =20, Left =30, Height =180, Width =300)
dg.BackColor <- Color.LightBlue
let btn = new Button(Top = 200, Left =50,Height =20, Width =60)
btn.BackColor <- Color.LightSeaGreen
btn.Text <- "Update"
frm.Controls.Add(dg)
frm.Controls.Add(btn)

//---------------- Creating DataAdapter
let da = new SqlDataAdapter("select * from std_record", constr)

//---------------- Creating DataSet
let ds = new DataSet()
da.Fill(ds)|>ignore
dg.DataSource <- ds.Tables.[0]

//----------------- Button Click
btn.Click.Add(fun _->
//---------------- Creating CommandBuilder
let comndbuil = new SqlCommandBuilder(da)
da.Update(ds)|>ignore
MessageBox.Show("Record Updated")|>ignore
)
Application.Run(frm)



for More Help Visit on Following link...............
http://www.c-sharpcorner.com/UploadFile/718fc8/updating-record-using-commandbuilder-class-in-fsharp/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900