open System
open System.Windows.Forms
open System.Data
open System.Data.SqlClient
open System.Drawing
let constring = @"Data Source=MCNDESKTOP34;Initial Catalog=Employee;User ID=; Password="
let con=new SqlConnection(constring)
let dataadpter = new SqlDataAdapter("Select * from EmployeeInfo", con)
let ds = new DataSet()
dataadpter.Fill(ds,"EmployeeInfo")|>ignore
let ffont=new Font("Verdana", 9.75F,FontStyle.Regular, GraphicsUnit.Point)
let databindform = new Form(Text="DataBinding")
let lblEmpid=new Label(Text="EmpId:",Top=20,Left=40,Width=60)
let lblEmpname=new Label(Text="Emp Name:",Top=60,Left=0,Width=100)
let lblEmpdept=new Label(Text="Emp Department:",Top=100,Left=0,Width=130)
let exitbutton=new Button(Text="Exit",Top=150,Left=70)
let lblid=new Label(Top=20,Left=160,BorderStyle=BorderStyle.FixedSingle,Width=40)
let lblname=new Label(Top=60,Left=140,BorderStyle=BorderStyle.FixedSingle,Width=120)
let lbldept=new Label(Top=100,Left=140,BorderStyle=BorderStyle.FixedSingle,Width=120)
databindform.Font<-ffont
databindform.Controls.Add(exitbutton)
databindform.Controls.Add(lblEmpid)
databindform.Controls.Add(lblEmpname)
databindform.Controls.Add(lblEmpdept)
databindform.Controls.Add(lblid)
databindform.Controls.Add(lblname)
databindform.Controls.Add(lbldept)
lblid.DataBindings.Add(new Binding("Text",ds,"EmployeeInfo.Empid"))
lblname.DataBindings.Add(new Binding("Text",ds,"EmployeeInfo.Emp_Name"))
lbldept.DataBindings.Add(new Binding("Text",ds,"EmployeeInfo.Emp_Department"))
exitbutton.Click.Add(fun exit->
databindform.Close()
con.Close())
databindform.Show()
Application.Run(databindform)