数据绑定问题。 [英] Issue with Databinding.

查看:76
本文介绍了数据绑定问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,希望有人来帮助我。我是.NET的初学者,试图学习DataBinding概念。我用数据集绑定了4个文本

框但是当我说adapter.update它给了我0个记录

更新了!我没有任何例外。以下是完整的代码。有人

请帮帮我。


使用系统;

使用System.Drawing;

使用System.Collections;

使用System.ComponentModel;

使用System.Windows.Forms;

使用System.Data;


命名空间ADO.NET

{

///< summary>

///摘要描述Form1。

///< / summary>

公共类frmMain:System.Windows.Forms.Form

{

private System.Windows.Forms.Label lblEmpName;

private System.Windows.Forms.Label lblEmplId;

private System.Windows.Forms.Label lblDesignation;

private System.Windows.Forms.Label lblSex;

private System.Windows.Forms.TextBox txtEmpName;

private System.Windows.Forms .TextBox txtEmpID;

private System.Windows.Forms.TextBox txtDesignation;

private System.Windows.Forms.TextBox txtSex;

private System .Windows.Forms.Button btn删除;

private System.Windows.Forms.Button btnInsert;

private System.Windows.Forms.Button btnUpdate;

private System.Windows .Forms.GroupBox grpSeek;

private System.Windows.Forms.GroupBox grpModify;

private System.Windows.Forms.Button btnPrevious;

private System.Windows.Forms.Button btnNext;

private System.Windows.Forms.Button btnLast;

private System.Windows.Forms.Button btnFirst;

private System.Windows.Forms.GroupBox grpData;

private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;

private System.Data.SqlClient.SqlCommand sqlSelectCommand1;

private System.Data.SqlClient.SqlCommand sqlInsertCommand1;

private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;

private System.Data.SqlClient .SqlCommand sqlDeleteCommand1;

private System.Data.SqlClient.SqlConnection sqlConnection1;

private ADO.NET.DataSet1 dataSet 11;

///< summary>

///所需的设计师变量。

///< / summary>

private System.ComponentModel.Container components = null;


public frmMain()

{

/ /

// Windows窗体设计器支持需要

//

InitializeComponent();


//

// TODO:在InitializeComponent调用后添加任何构造函数代码

//

}


///< summary>

///清理正在使用的所有资源。

///< / summary>

protected override void Dispose(bool disposing)

{

if(disposing)

{

if(组件!= null)

{

components.Dispose();

}

}

base.Dispose(disposing);

}


#region Windows窗体设计器生成的代码

/// < summary>

/// Designer的必需方法支持 - 请勿使用代码编辑器修改

///此方法的内容。

///< / summary>

private void InitializeComponent()

{

this.lblEmpName = new System.Windows.Forms.Label();

this.lblEmplId = new System.Windows.Forms.Label();

this.lblDesignation = new System.Windows.Forms.Label();

this.lblSex = new System.Windows。 Forms.Label();

this.txtEmpName = new System.Windows.Forms.TextBox();

this.dataSet11 = new ADO.NET.DataSet1();

this.txtEmpID = new System.Windows.Forms.TextBox();

this.txtDesignation = new System.Windows.Forms.TextBox();

this.txtSex = new System.Windows.Forms.TextBox();

this.btnPrevious = new System.Windows.Forms.Button();

this.btnNext = new System.Windows.Forms.Button();

this.btnDelete = new System.Windows.Forms.Button();

this.btnInsert =新的System.Windows.Forms.Button();

this.btnUpdate = new System.Windows.Forms.Button();

this.grpSeek = new System.Windows.Forms.GroupBox();

this.btnFirst = new System.Windows.Forms.Button();

this.btnLast = new System.Windows.Forms.Button();

this.grpModify = new System.Windows.Forms.GroupBox();

this.grpData = new System.Windows.Forms.GroupBox();

this.sqlDataAdapter1 = new System.Data .SqlClient.SqlDataAdapter();

this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlConnection1 = new System.Data.SqlClient.SqlConnection ();

this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();

((System.ComponentModel.ISupportInitialize)(this.d ataSet11))。BeginInit();

this.grpSeek.SuspendLayout();

this.grpModify.SuspendLayout();

this.grpData.SuspendLayout();

this.SuspendLayout();

//

// lblEmpName

//

this.lblEmpName.AutoSize = true;

this.lblEmpName.Location = new System.Drawing.Point(8,24 );

this.lblEmpName.Name =" lblEmpName";

this.lblEmpName.Size = new System.Drawing.Size(88,16);

this.lblEmpName.TabIndex = 0;

this.lblEmpName.Text =" Employee Name";

//

// lblEmplId

//

this.lblEmplId.AutoSize = true;

this.lblEmplId.Location = new System.Drawing.Point (8,64);

this.lblEmplId.Name =" lblEmplId";

this.lblEmplId.Size = new System.Drawing.Size(67,16) ;

this.lblEmplId.TabIndex = 0;

this.lblEmplId.Text =" Employee Id";

//

// lblDesignation

//

this.lblDesignation.AutoSize = true;

this.lblDesignation.Location = new System.Drawing.Point(8,104);

this.lblDesignation.Name =" lblDesignation";

this.lblDesignation.Size = new System.Drawing。大小(64,16);

this.lblDesignation.TabIndex = 0;

this.lblDesignation.Text =" Designation";

//

// lblSex

//

this.lblSex.AutoSize = true;

this.lblSex .Location = new System.Drawing.Point(8,144);

this.lblSex.Name =" lblSex";

this.lblSex.Size = new System .Drawing.Size(24,16);

this.lblSex.TabIndex = 0;

this.lblSex.Text =" Sex";

//

// txtEmpName

//

this.txtEmpName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.txtEmpName.DataBindings.Add(new System.Windows.Forms.Binding(" Text",

this.dataSet11," Employee.Employee")) ;

this.txtEmpName.Location = new System.Drawing.Point(104,24) ;

this.txtEmpName.Name =" txtEmpName" ;;

this.txtEmpName.Size = new System.Drawing.Size(96,20);

this.txtEmpName.TabIndex = 1;

this.txtEmpName.Text ="" ;;

//

/ / dataSet11

//

this.dataSet11.DataSetName =" DataSet1";

this.dataSet11.Locale = new System.Globalization。 CultureInfo(en-US);

//

// txtEmpID

//

this .txtEmpID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.txtEmpID.DataBindings.Add(new System.Windows.Forms.Binding(" Text",

this.dataSet11," Employee.EmpId"));

this.txtEmpID.Location = new System.Drawing.Point(104,64);

this.txtEmpID.Name =" txtEmpID";

this.txtEmpID.Size = new System.Drawing.Size(96,20);

this.txtEmpID.TabIndex = 1;

this.txtEmpID.Text ="" ;;

//

// txtDesignation

//

this.txtDesignation.BorderStyle =

System.Windows.Forms.BorderStyle.FixedSingle ;

this.txtDesignation.DataBindings.Add(new

System.Windows.Forms.Binding(" Text",this.dataSet11," Employee.Designation")) );

this.txtDesignation.Location = new System.Drawing.Point(104,104);

this.txtDesignation.Name =" txtDesignation" ;;

this.txtDesignation.Size = new System.Drawing.Size(96,20);

this.txtDesignation.TabIndex = 1;

this.txtDesignation .Text ="";

//

// txtSex

//

this.txtSex .BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.txtSex.DataBindings.Add(new System.Windows.Forms.Binding(" Text",

this.dataSet11," Employee.Sex"));

this.txtSex.Location = new System.Drawing.Point(104,144);

this。 txtSex.Name =" txtSex" ;;

this.txtSex.Size = new System.Drawing.Size(96,20);

this.txtSex.TabIndex = 1;

this.txtSex.Text ="" ;;

//

// btnPrevious

//

this.btnPrevious.Location = new System.Drawing.Point(56,24);

this.btnPrevious.Name =" btnPrevious";

this。 btnPrevious.Size = new System.Drawing.Size(32,23);

this.btnPrevious.TabIndex = 2;

this.btnPrevious.Text ="< " ;;

this.btnPrevious.Click + = new System.EventHandler(this.btnPrevious_Click);

//

// btnNext < br $>
//

this.btnNext.Location = new System.Drawing.Point(112,24);

this.btnNext.Name =" ; btnNext" ;;

this.btnNext.Size = new System.Drawing.Size(32,23);

this.btnNext.TabIndex = 3;

this.btnNext.Text =">" ;;

this.btnNext.Click + = new System.EventHandler(this.btnNext_Click);

//

// btnDelete

//

this.btnDelete.Location = new System.Drawing.Point(112, 24);

this.btnDelete.Name =" btnDelete";

this.btnDelete.Size = new System.Drawing.Size(80,23);

this.btnDelete.TabIndex = 4;

this.btnDelete.Text ="删除";

//

// btnInsert

//

this.btnInsert.Location = new System.Drawing.Point(8,64);

this。 btnInsert.Name =" btnInsert";

this.btnInsert.Size = new System.Drawing.Size(184,23);

this.btnInsert.TabIndex = 5 ;

this.btnInsert.Text =" Insert";

//

// btnUpdate

/ /

this.btnUpdate.Location = new System.Drawing.Point(8,24);

this.btnUpdate.Name =" btnUpdate";

this.btnUpdate.Size = new System.Drawing.Size(80,23);

this.btnUpdate.TabIndex = 6;

this.btnUpdate。 Text =" Updat e" ;;

this.btnUpdate.Click + = new System.EventHandler(this.btnUpdate_Click);

//

// grpSeek < br $>
//

this.grpSeek.Controls.Add(this.btnFirst);

this.grpSeek.Controls.Add(this.btnLast) ;

this.grpSeek.Controls.Add(this.btnNext);

this.grpSeek.Controls.Add(this.btnPrevious);

this.grpSeek.Location = new System.Drawing.Point(224,8);

this.grpSeek.Name =" grpSeek";

this.grpSeek。 Size = new System.Drawing.Size(200,72);

this.grpSeek.TabIndex = 7;

this.grpSeek.TabStop = false;

this.grpSeek.Text =" Seek";

//

// btnFirst

//

this.btnFirst.Location = new System.Drawing.Point(8,24);

this.btnFirst.Name =" btnFirst";

this .btnFirst.Size = new System.Drawing.Size(32,23);

this.btnFirst.TabIndex = 5;

this.btnFirst.Text =" | <<英寸;

this.btnFirst.Click + = new System.EventHandler(this.btnFirst_Click);

//

// btnLast

//

this.btnLast.Location = new System.Drawing.Point(160,24);

this.btnLast.Name =" btnLast" ;

this.btnLast.Size = new System.Drawing.Size(32,23);

this.btnLast.TabIndex = 4;

this.btnLast.Text =">> |" ;;

this.btnLast.Click + = new System.EventHandler(this.btnLast_Click);

//

// grpModify

//

this.grpModify.Controls.Add(this.btnUpdate);

this.grpModify.Controls.Add(this.btnDelete);

this.grpModify.Controls.Add(this.btnInsert);

this.grpModify.Location = new System.Drawing.Point(224,88);

this.grpModify.Name =" grpModify";

this.grpModify.Size = new System.Drawing。大小(200,96);

this.grpModify.TabIndex = 8;

this.grpModify.TabStop = false;

this .grpModify.Text ="修改" ;;

//

// grpData

//

这个.grpData.Controls.Add(this.txtSex);

this.grpData.Controls.Add(this.lblSex);

this.grpData.Controls.Add(this .txtDesignation);

this.grpData.Controls.Add(this.lblDesignation);

this.grpData.Controls.Add(this.lblEmplId);

this.grpData.Controls.Add(this.txtEmpName);

this.grpData.Controls.Add(this.txtEmpID);

this.grpData。 Controls.Add(this.lblEmpName);

this.grpData.Location = new System.Drawing.Point(8,8);

this.grpData.Name =" ; grpData" ;;

this.grpData.Size = new System.Drawing.Size(208,176);

this.grpData.TabIndex = 9;

this.grpData.TabStop = false;

this.grpData.Text =" Data";

//

/ / sqlDataAdapter1

//

this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;

this.sqlDataAdapter1。 InsertCommand = this.sqlInsertCommand1;

this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;

this.sqlDataAdapter1.TableMappings.AddRange(new

System .Data.Common.DataTableMapping [] {

new System.Data.Common.DataTableMapping(" Table",

" Employee",new System.Data.Common .DataColumnMapping [] {

new

System.Data.Common.DataColumnMapping(" Employee"," Employee"),

new

System.Data.Common.DataColumnMapping(" EmpId"," EmpId"),

new

System.Data.Common。 DataColumnMapping(" Sex"," Sex"),

new

System.Data.Common.DataColumnMapping(" Designation" ,指定)}}}};

this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;

//

// sqlDeleteCommand1

//

this.sqlDeleteCommand1.CommandText = @" DELETE FROM Employee WHERE(EmpId

= @Original_EmpId)AND(指定= @ Original_Designation或

@Original_Designation IS NULL AND Designation IS NULL)AND(Employee =

@Original_Employee OR @Original_Employee IS NULL AND Employee IS NULL)AND

(性别= @Original_Sex或@Original_Sex为空,性别为空)" ;;

this.sqlDeleteCommand1.Connection = this.sqlConnection1;

this.sqlDeleteCommand1。 Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @Original_EmpI d,

System.Data.SqlDbType.Decimal,9,System.Data。 ParameterDirection.Input,

false,((System.Byte)(18)),((System.Byte)(0)),EmpId,

系统.Data.DataRowVersion.Original,null));

this.sqlDeleteCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @Original_Desi gnation",

System.Data.SqlDbType.VarChar,50 ,System.Data.ParameterDirection.Input,

false,((System.Byte)(0)),((System.Byte)(0)),指定,

System.Data.DataRowVersion.Original,null));

this.sqlDeleteCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter(" ; @Original_Empl oyee",

System.Data.SqlDbType.VarChar,50,System.Data.ParameterDirection.Input,

false,((System.Byte)(0 )),((System.Byte)(0)),Employee,

System.Data.DataRowVersion.Original,null));

this.sqlDeleteCommand1 .Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @ Original_Sex" ,

System.Data.SqlDbType.VarChar,10,System.Data.ParameterDirection.Input,

false,((System.Byte)(0)),(( System.Byte)(0)),性别,

System.Data.DataRowVersion.Original,null));

//

// sqlConnection1

//

this.sqlConnection1.ConnectionString ="工作站

id = \" B3-AVON- HF04 \" ;;包大小= 4096;用户id = sa;数据源= \"。\" ;; persist" +

"安全信息=错误;初始目录= Gokul" ;;

//

// sqlInsertCommand1

//

this.sqlInsertCommand1.CommandText =" INSERT INTO Employee(Employee,

EmpId,Sex,Designation)VALUES(@Employee,@ EmpId" +

",@ Sex , @指定); SELECT员工,企业,性别,指定来自

员工WH" +

" ERE(EmpId = @EmpId)";

this.sqlInsertCommand1.Connection = this.sqlConnection1;

this.sqlInsertCommand1 .Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @ Employee",

System.Data.SqlDbType.VarChar,50," Employee" ));

this.sqlInsertCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @ EmpId",System.Data.SqlDbType.Decimal,

9,System.Data.ParameterDirection.Input,false,((System.Byte)(18)),

((System.Byte)(0)), " EmpId",System.Data.DataRowVersion.Current,null));

this.sqlInsertCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter( @ Sex,System.Data.SqlDbType.VarChar,10,

" Sex"));

this.sqlInsertCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @ Designation",

System.Data.SqlDbType.VarChar,50," Designatio n));

//

// sqlSelectCommand1

//

this.sqlSelectCommand1.CommandText = SELECT Employee,EmpId,Sex,

从Employee指定;

this.sqlSelectCommand1.Connection = this.sqlConnection1;

//

// sqlUpdateCommand1

//

this.sqlUpdateCommand1.CommandText = @" UPDATE员工SET员工=

@Employee,EmpId = @EmpId,Sex = @Sex,Designation = @Designation WHERE

(EmpId = @Original_EmpId)AND(指定= @Original_Designation或

@Original_Designation IS NULL和指定IS NULL)AND(Employee =

@Original_Employee OR @Original_Employee IS NULL和Employee IS NULL)和

(性别= @Original_Sex或@Original_Sex IS NULL AND Sex IS NULL); SELECT

员工,EmpId,性别,指定来自员工WHERE(EmpId = @EmpId)" ;;

this.sqlUpdateCommand1.Connection = this.sqlConnection1;

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @ Employee",

System.Data.SqlDbType.VarChar ,50,Employee));

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @EmpId",System .Data.SqlDbType.Decimal,

this.sqlUpdateCommand1.Parameters.Add(new

System .Data.SqlClient.SqlParameter(" @ Sex",System.Data.SqlDbType.VarChar,10,

" Sex"));

this.sqlUpdateCommand1。 Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @ Designation",

Sy stem.Data.SqlDbType.VarChar,50,Designation));

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter( @Original_EmpI d,

System.Data.SqlDbType.Decimal,9,System.Data.ParameterDirection.Input,

false,((System.Byte)( 18)),((System.Byte)(0)),EmpId,

System.Data.DataRowVersion.Original,null));

this。 sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @Original_Desi gnation),

System.Data.SqlDbType.VarChar,50,System。 Data.ParameterDirection.Input,

false,((System.Byte)(0)),((System.Byte)(0)),指定,

System.Data.DataRowVersion.Original,null));

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @Original_Empl oyee",

System.Data.SqlDbType.VarChar,50,System.Data.ParameterDirection.Input,

false, ((System.Byte)(0)),((System.Byte)(0)),Employee,

System.Data.DataRowVersion.Original,null));

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter(" @ Original_Sex" ,

System.Data.SqlDbType.VarChar,10,System.Data.ParameterDirection.Input,

false,((System.Byte)(0)),(( System.Byte)(0)),性别,

System.Data.DataRowVersion.Original,null));

//

// frmMain

//

this.AutoScaleBaseSize = new System.Drawing.Size(5,13);

this.ClientSize = new System.Drawing.Size(432,190);

this.Controls.Add(this.grpData);

this.Controls.Add(this.grpModify) ;

this.Controls.Add(this.grpSeek);

this.MaximizeBox = false;

this.MinimizeBox = false;

this.Name =" frmMain";

this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n;

this.Text = 简单数据绑定;

this.Load + = new System.EventHandler(this.frmMain_Load);

((System.ComponentModel.ISupportInitialize)(this.d ataSet11))。EndInit();

this.grpSeek.ResumeLayout(false);

this.grpModify.ResumeLayout(false);

this.grpData.ResumeLayout(false);

this.ResumeLayout(false);


}

#endregion


///< summary>

///主要切入点申请。

///< / summary>

[STAThread]

static void Main()

{

Application.Run(new frmMain());

}


private void frmMain_Load(object sender,System .EventArgs e)

{

试试

{


sqlDataAdapter1.Fill(dataSet11," ;员工" );


}


catch(例外情况)

{


MessageBox.Show(Ex.Message);

}


}


private void btnNext_Click(对象发送者,System.EventArgs e)

{

尝试

{


if(this .BindingContext [dataSet11," Employee"] .Position!=

this.BindingContext [dataSet11," Employee"] .Count - 1)


this.BindingContext [dataSet11," Employee" ] .Position + = 1;


else


MessageBox.Show(" EOF reach);

}


catch(例外情况)

{


MessageBox.Show(例如。消息);

}


返回;

}


private void btnPrevious_Click (对象发送者,System.EventArgs e)

{


尝试

{


if(this.BindingContext [dataSet11," Employee"] .Position!= 0)

this.BindingContext [dataSet11," Employee" ] .Position - = 1;


else


MessageBox.Show(" EOB reach);


}


catch(例外情况)

{


MessageBox.Show(例如。消息);

}


返回;


}


private void btnFirst_Click(object sender,System.EventArgs e)

{

try

{


this.BindingContext [dataSet11," Employee" ] .Position = 0;


}


catch(例外情况)

{


MessageBox.Show(Ex.Message);

}


返回;

}


private void btnLast_Click(object sender,System.EventArgs e)

{

try

{


this.BindingContext [dataSet11," Employee" ] .Position =

this.BindingContext [dataSet11," Employee" ] .Count - 1;


}


catch(例外情况)

{


MessageBox.Show(Ex.Message);

}


返回;

}


private void btnUpdate_Click(object sender,System.EventArgs e)

{


try

$

MessageBox.Show(" Records Affected - " + sqlDataAdapter1.Update(

dataSet11).ToString());


}


catch(例外情况)

{


MessageBox。显示(Ex.Message);

}


返回;


}

}

}

I am struck up with a problem and want anyone here to help me out. I am a
beginner in .NET trying to learng DataBinding concepts. I have binded 4 text
boxes with a dataset but when I say adapter.update it gives me 0 records
updated! I am not getting any exceptions. Below is the complete code. Someone
please help me out.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ADO.NET
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblEmpName;
private System.Windows.Forms.Label lblEmplId;
private System.Windows.Forms.Label lblDesignation;
private System.Windows.Forms.Label lblSex;
private System.Windows.Forms.TextBox txtEmpName;
private System.Windows.Forms.TextBox txtEmpID;
private System.Windows.Forms.TextBox txtDesignation;
private System.Windows.Forms.TextBox txtSex;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.Button btnInsert;
private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.GroupBox grpSeek;
private System.Windows.Forms.GroupBox grpModify;
private System.Windows.Forms.Button btnPrevious;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnLast;
private System.Windows.Forms.Button btnFirst;
private System.Windows.Forms.GroupBox grpData;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private ADO.NET.DataSet1 dataSet11;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public frmMain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblEmpName = new System.Windows.Forms.Label();
this.lblEmplId = new System.Windows.Forms.Label();
this.lblDesignation = new System.Windows.Forms.Label();
this.lblSex = new System.Windows.Forms.Label();
this.txtEmpName = new System.Windows.Forms.TextBox();
this.dataSet11 = new ADO.NET.DataSet1();
this.txtEmpID = new System.Windows.Forms.TextBox();
this.txtDesignation = new System.Windows.Forms.TextBox();
this.txtSex = new System.Windows.Forms.TextBox();
this.btnPrevious = new System.Windows.Forms.Button();
this.btnNext = new System.Windows.Forms.Button();
this.btnDelete = new System.Windows.Forms.Button();
this.btnInsert = new System.Windows.Forms.Button();
this.btnUpdate = new System.Windows.Forms.Button();
this.grpSeek = new System.Windows.Forms.GroupBox();
this.btnFirst = new System.Windows.Forms.Button();
this.btnLast = new System.Windows.Forms.Button();
this.grpModify = new System.Windows.Forms.GroupBox();
this.grpData = new System.Windows.Forms.GroupBox();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
((System.ComponentModel.ISupportInitialize)(this.d ataSet11)).BeginInit();
this.grpSeek.SuspendLayout();
this.grpModify.SuspendLayout();
this.grpData.SuspendLayout();
this.SuspendLayout();
//
// lblEmpName
//
this.lblEmpName.AutoSize = true;
this.lblEmpName.Location = new System.Drawing.Point(8, 24);
this.lblEmpName.Name = "lblEmpName";
this.lblEmpName.Size = new System.Drawing.Size(88, 16);
this.lblEmpName.TabIndex = 0;
this.lblEmpName.Text = "Employee Name";
//
// lblEmplId
//
this.lblEmplId.AutoSize = true;
this.lblEmplId.Location = new System.Drawing.Point(8, 64);
this.lblEmplId.Name = "lblEmplId";
this.lblEmplId.Size = new System.Drawing.Size(67, 16);
this.lblEmplId.TabIndex = 0;
this.lblEmplId.Text = "Employee Id";
//
// lblDesignation
//
this.lblDesignation.AutoSize = true;
this.lblDesignation.Location = new System.Drawing.Point(8, 104);
this.lblDesignation.Name = "lblDesignation";
this.lblDesignation.Size = new System.Drawing.Size(64, 16);
this.lblDesignation.TabIndex = 0;
this.lblDesignation.Text = "Designation";
//
// lblSex
//
this.lblSex.AutoSize = true;
this.lblSex.Location = new System.Drawing.Point(8, 144);
this.lblSex.Name = "lblSex";
this.lblSex.Size = new System.Drawing.Size(24, 16);
this.lblSex.TabIndex = 0;
this.lblSex.Text = "Sex";
//
// txtEmpName
//
this.txtEmpName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtEmpName.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataSet11, "Employee.Employee"));
this.txtEmpName.Location = new System.Drawing.Point(104, 24);
this.txtEmpName.Name = "txtEmpName";
this.txtEmpName.Size = new System.Drawing.Size(96, 20);
this.txtEmpName.TabIndex = 1;
this.txtEmpName.Text = "";
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("en-US");
//
// txtEmpID
//
this.txtEmpID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtEmpID.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataSet11, "Employee.EmpId"));
this.txtEmpID.Location = new System.Drawing.Point(104, 64);
this.txtEmpID.Name = "txtEmpID";
this.txtEmpID.Size = new System.Drawing.Size(96, 20);
this.txtEmpID.TabIndex = 1;
this.txtEmpID.Text = "";
//
// txtDesignation
//
this.txtDesignation.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.txtDesignation.DataBindings.Add(new
System.Windows.Forms.Binding("Text", this.dataSet11, "Employee.Designation"));
this.txtDesignation.Location = new System.Drawing.Point(104, 104);
this.txtDesignation.Name = "txtDesignation";
this.txtDesignation.Size = new System.Drawing.Size(96, 20);
this.txtDesignation.TabIndex = 1;
this.txtDesignation.Text = "";
//
// txtSex
//
this.txtSex.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtSex.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataSet11, "Employee.Sex"));
this.txtSex.Location = new System.Drawing.Point(104, 144);
this.txtSex.Name = "txtSex";
this.txtSex.Size = new System.Drawing.Size(96, 20);
this.txtSex.TabIndex = 1;
this.txtSex.Text = "";
//
// btnPrevious
//
this.btnPrevious.Location = new System.Drawing.Point(56, 24);
this.btnPrevious.Name = "btnPrevious";
this.btnPrevious.Size = new System.Drawing.Size(32, 23);
this.btnPrevious.TabIndex = 2;
this.btnPrevious.Text = "<";
this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
//
// btnNext
//
this.btnNext.Location = new System.Drawing.Point(112, 24);
this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(32, 23);
this.btnNext.TabIndex = 3;
this.btnNext.Text = ">";
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
//
// btnDelete
//
this.btnDelete.Location = new System.Drawing.Point(112, 24);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(80, 23);
this.btnDelete.TabIndex = 4;
this.btnDelete.Text = "Delete";
//
// btnInsert
//
this.btnInsert.Location = new System.Drawing.Point(8, 64);
this.btnInsert.Name = "btnInsert";
this.btnInsert.Size = new System.Drawing.Size(184, 23);
this.btnInsert.TabIndex = 5;
this.btnInsert.Text = "Insert";
//
// btnUpdate
//
this.btnUpdate.Location = new System.Drawing.Point(8, 24);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(80, 23);
this.btnUpdate.TabIndex = 6;
this.btnUpdate.Text = "Update";
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
//
// grpSeek
//
this.grpSeek.Controls.Add(this.btnFirst);
this.grpSeek.Controls.Add(this.btnLast);
this.grpSeek.Controls.Add(this.btnNext);
this.grpSeek.Controls.Add(this.btnPrevious);
this.grpSeek.Location = new System.Drawing.Point(224, 8);
this.grpSeek.Name = "grpSeek";
this.grpSeek.Size = new System.Drawing.Size(200, 72);
this.grpSeek.TabIndex = 7;
this.grpSeek.TabStop = false;
this.grpSeek.Text = "Seek";
//
// btnFirst
//
this.btnFirst.Location = new System.Drawing.Point(8, 24);
this.btnFirst.Name = "btnFirst";
this.btnFirst.Size = new System.Drawing.Size(32, 23);
this.btnFirst.TabIndex = 5;
this.btnFirst.Text = "|<<";
this.btnFirst.Click += new System.EventHandler(this.btnFirst_Click);
//
// btnLast
//
this.btnLast.Location = new System.Drawing.Point(160, 24);
this.btnLast.Name = "btnLast";
this.btnLast.Size = new System.Drawing.Size(32, 23);
this.btnLast.TabIndex = 4;
this.btnLast.Text = ">>|";
this.btnLast.Click += new System.EventHandler(this.btnLast_Click);
//
// grpModify
//
this.grpModify.Controls.Add(this.btnUpdate);
this.grpModify.Controls.Add(this.btnDelete);
this.grpModify.Controls.Add(this.btnInsert);
this.grpModify.Location = new System.Drawing.Point(224, 88);
this.grpModify.Name = "grpModify";
this.grpModify.Size = new System.Drawing.Size(200, 96);
this.grpModify.TabIndex = 8;
this.grpModify.TabStop = false;
this.grpModify.Text = "Modify";
//
// grpData
//
this.grpData.Controls.Add(this.txtSex);
this.grpData.Controls.Add(this.lblSex);
this.grpData.Controls.Add(this.txtDesignation);
this.grpData.Controls.Add(this.lblDesignation);
this.grpData.Controls.Add(this.lblEmplId);
this.grpData.Controls.Add(this.txtEmpName);
this.grpData.Controls.Add(this.txtEmpID);
this.grpData.Controls.Add(this.lblEmpName);
this.grpData.Location = new System.Drawing.Point(8, 8);
this.grpData.Name = "grpData";
this.grpData.Size = new System.Drawing.Size(208, 176);
this.grpData.TabIndex = 9;
this.grpData.TabStop = false;
this.grpData.Text = "Data";
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new
System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table",
"Employee", new System.Data.Common.DataColumnMapping[] {
new
System.Data.Common.DataColumnMapping("Employee", "Employee"),
new
System.Data.Common.DataColumnMapping("EmpId", "EmpId"),
new
System.Data.Common.DataColumnMapping("Sex", "Sex"),
new
System.Data.Common.DataColumnMapping("Designation" , "Designation")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM Employee WHERE (EmpId
= @Original_EmpId) AND (Designation = @Original_Designation OR
@Original_Designation IS NULL AND Designation IS NULL) AND (Employee =
@Original_Employee OR @Original_Employee IS NULL AND Employee IS NULL) AND
(Sex = @Original_Sex OR @Original_Sex IS NULL AND Sex IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_EmpI d",
System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input,
false, ((System.Byte)(18)), ((System.Byte)(0)), "EmpId",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Desi gnation",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Designation",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Empl oyee",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Employee",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Sex" ,
System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Sex",
System.Data.DataRowVersion.Original, null));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation
id=\"B3-AVON-HF04\";packet size=4096;user id=sa;data source=\".\";persist" +
" security info=False;initial catalog=Gokul";
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO Employee(Employee,
EmpId, Sex, Designation) VALUES (@Employee, @EmpId" +
", @Sex, @Designation); SELECT Employee, EmpId, Sex, Designation FROM
Employee WH" +
"ERE (EmpId = @EmpId)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Employee",
System.Data.SqlDbType.VarChar, 50, "Employee"));
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@EmpId", System.Data.SqlDbType.Decimal,
9, System.Data.ParameterDirection.Input, false, ((System.Byte)(18)),
((System.Byte)(0)), "EmpId", System.Data.DataRowVersion.Current, null));
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Sex", System.Data.SqlDbType.VarChar, 10,
"Sex"));
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Designation",
System.Data.SqlDbType.VarChar, 50, "Designation"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT Employee, EmpId, Sex,
Designation FROM Employee";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE Employee SET Employee =
@Employee, EmpId = @EmpId, Sex = @Sex, Designation = @Designation WHERE
(EmpId = @Original_EmpId) AND (Designation = @Original_Designation OR
@Original_Designation IS NULL AND Designation IS NULL) AND (Employee =
@Original_Employee OR @Original_Employee IS NULL AND Employee IS NULL) AND
(Sex = @Original_Sex OR @Original_Sex IS NULL AND Sex IS NULL); SELECT
Employee, EmpId, Sex, Designation FROM Employee WHERE (EmpId = @EmpId)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Employee",
System.Data.SqlDbType.VarChar, 50, "Employee"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@EmpId", System.Data.SqlDbType.Decimal,
9, System.Data.ParameterDirection.Input, false, ((System.Byte)(18)),
((System.Byte)(0)), "EmpId", System.Data.DataRowVersion.Current, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Sex", System.Data.SqlDbType.VarChar, 10,
"Sex"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Designation",
System.Data.SqlDbType.VarChar, 50, "Designation"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_EmpI d",
System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input,
false, ((System.Byte)(18)), ((System.Byte)(0)), "EmpId",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Desi gnation",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Designation",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Empl oyee",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Employee",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Sex" ,
System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Sex",
System.Data.DataRowVersion.Original, null));
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(432, 190);
this.Controls.Add(this.grpData);
this.Controls.Add(this.grpModify);
this.Controls.Add(this.grpSeek);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n;
this.Text = "Simple Data Binding";
this.Load += new System.EventHandler(this.frmMain_Load);
((System.ComponentModel.ISupportInitialize)(this.d ataSet11)).EndInit();
this.grpSeek.ResumeLayout(false);
this.grpModify.ResumeLayout(false);
this.grpData.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmMain());
}

private void frmMain_Load(object sender, System.EventArgs e)
{
try
{

sqlDataAdapter1.Fill ( dataSet11,"Employee" ) ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

}

private void btnNext_Click(object sender, System.EventArgs e)
{
try
{

if ( this.BindingContext[dataSet11 , "Employee" ].Position !=
this.BindingContext[dataSet11 , "Employee" ].Count - 1 )

this.BindingContext[dataSet11 , "Employee" ].Position += 1 ;

else

MessageBox.Show ( "EOF reached" ) ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

return ;
}

private void btnPrevious_Click(object sender, System.EventArgs e)
{

try
{

if ( this.BindingContext[dataSet11 , "Employee" ].Position != 0 )

this.BindingContext[dataSet11 , "Employee" ].Position -= 1 ;

else

MessageBox.Show ( "EOB reached" ) ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

return ;

}

private void btnFirst_Click(object sender, System.EventArgs e)
{
try
{

this.BindingContext[dataSet11 , "Employee" ].Position = 0 ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

return ;
}

private void btnLast_Click(object sender, System.EventArgs e)
{
try
{

this.BindingContext[dataSet11 , "Employee" ].Position =
this.BindingContext[dataSet11 , "Employee" ].Count - 1 ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

return ;
}

private void btnUpdate_Click( object sender, System.EventArgs e )
{

try
{

MessageBox.Show ( "Records Affected - " + sqlDataAdapter1.Update(
dataSet11 ).ToString ( ) ) ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

return ;

}

}
}

推荐答案




我没有仔细查看你的代码,但看起来好像

更改没有在你开始更新之前反映在你的数据集中

方法你的tableAdapter。看看你的DataSet上的AcceptChanges方法

......

http://msdn2.microsoft.com/en-us/lib...ptchanges.aspx


亲切的问候,

25月8日,08:39,Gokul< G ... @ discussion.microsoft.comwrote:
Hi,

I haven''t looked at your code very thoroughly but it looks as if the
changes are not reflected in your dataset before you start the update
method of your tableAdapter. Take a look at the AcceptChanges method
on your DataSet...

http://msdn2.microsoft.com/en-us/lib...ptchanges.aspx

Kind regards,
On 25 jan, 08:39, Gokul <G...@discussions.microsoft.comwrote:

我遇到了问题,希望有人帮助我。我是.NET的初学者,试图学习DataBinding概念。我用数据集绑定了4个文本

框但是当我说adapter.update它给了我0个记录

更新了!我没有任何例外。以下是完整的代码。有人

请帮帮我。


使用系统;

使用System.Drawing;

使用System.Collections;

使用System.ComponentModel;

使用System.Windows.Forms;

使用System.Data;


命名空间ADO.NET

{

///< summary>

///摘要描述Form1。

///< / summary>

公共类frmMain:System.Windows.Forms.Form

{

private System.Windows.Forms.Label lblEmpName;

private System.Windows.Forms.Label lblEmplId;

private System.Windows.Forms.Label lblDesignation;

private System.Windows.Forms.Label lblSex;

private System.Windows.Forms.TextBox txtEmpName;

private System.Windows.Forms .TextBox txtEmpID;

private S ystem.Windows.Forms.TextBox txtDesignation;

private System.Windows.Forms.TextBox txtSex;

private System.Windows.Forms.Button btnDelete;

private System.Windows.Forms.Button btnInsert;

private System.Windows.Forms.Button btnUpdate;

private System.Windows.Forms.GroupBox grpSeek;

private System.Windows.Forms.GroupBox grpModify;

private System.Windows.Forms.Button btnPrevious;

private System.Windows.Forms。按钮btnNext;

private System.Windows.Forms.Button btnLast;

private System.Windows.Forms.Button btnFirst;

private System。 Windows.Forms.GroupBox grpData;

private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;

private System.Data.SqlClient .SqlCommand sqlSelectCommand1;

private System.Data.SqlClient.SqlCommand sqlInsertCommand1;

private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;

private System .Data.SqlClient.SqlCommand sqlDeleteCommand1;

private System.Data.SqlClient.SqlConnection sqlConnection1;

private ADO.NET.DataSet1 dataSet11;

///< summary>

///所需的设计变量。

///< / summary>

private System.ComponentModel .Container components = null;


public frmMain()

{

//

/ / Windows表单设计器支持需要

//

InitializeComponent();


//

// TODO:在InitializeComponent调用后添加任何构造函数代码

//

}


///< summary>

///清理正在使用的所有资源。

///< / summary>

protected override void Dispose(bool disposing)

{

if(disposing)

{

if(components) != null)

{

components.Dispose();

}

}
$ b$b base.Dispose( disposing );

}


#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.lblEmpName = new System.Windows.Forms.Label();

this.lblEmplId = new System.Windows.Forms.Label();

this.lblDesignation = new System.Windows.Forms.Label();

this.lblSex = new System.Windows.Forms.Label();

this.txtEmpName = new System.Windows.Forms.TextBox();

this.dataSet11 = new ADO.NET.DataSet1();

this.txtEmpID = new System.Windows.Forms.TextBox();

this.txtDesignation = new Syste m.Windows.Forms.TextBox();

this.txtSex = new System.Windows.Forms.TextBox();

this.btnPrevious = new System.Windows.Forms.Button();

this.btnNext = new System.Windows.Forms.Button();

this.btnDelete = new System.Windows.Forms.Button();

this.btnInsert = new System.Windows.Forms.Button();

this.btnUpdate = new System.Windows.Forms.Button();

this.grpSeek = new System.Windows.Forms.GroupBox();

this.btnFirst = new System.Windows.Forms.Button();

this.btnLast = new System.Windows.Forms.Button();

this.grpModify = new System.Windows.Forms.GroupBox();

this.grpData = new System.Windows.Forms.GroupBox();

this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();

this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();

this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();

((System.ComponentModel.ISupportInitialize)(this.d ataSet11)).BeginInit();

this.grpSeek.SuspendLayout();

this.grpModify.SuspendLayout();

this.grpData.SuspendLayout();

this.SuspendLayout();

//

// lblEmpName

//

this.lblEmpName.AutoSize = true;

this.lblEmpName.Location = new System.Drawing.Point(8, 24);

this.lblEmpName.Name = "lblEmpName";

this.lblEmpName.Size = new System.Drawing.Size(88, 16);

this.lblEmpName.TabIndex = 0;

this.lblEmpName.Text = "Employee Name";

//

// lblEmplId

//

this.lblEmplId.AutoSize = true;

this.lblEmplId.Location = new System.Drawing.Point(8, 64);

this.lblEmplId.Name = "lblEmplId";

this.lblEmplId.Size = new System.Drawing. Size(67, 16);

this.lblEmplId.TabIndex = 0;

this.lblEmplId.Text = "Employee Id";

//

// lblDesignation

//

this.lblDesignation.AutoSize = true;

this.lblDesignation.Location = new System.Drawing.Point(8, 104);

this.lblDesignation.Name = "lblDesignation";

this.lblDesignation.Size = new System.Drawing.Size(64, 16);

this.lblDesignation.TabIndex = 0;

this.lblDesignation.Text = "Designation";

//

// lblSex

//

this.lblSex.AutoSize = true;

this.lblSex.Location = new System.Drawing.Point(8, 144);

this.lblSex.Name = "lblSex";

this.lblSex.Size = new System.Drawing.Size(24, 16);

this.lblSex.TabIndex = 0;

this.lblSex.Text = "Sex";

//

// txtEmpName

//

this.txtEmpName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.txtEmpName.DataBindings.Add(new System.Windows.Forms.Binding("Text",

this.dataSet11, "Employee.Employee"));

this.txtEmpName.Location = new System.Drawing.Point(104, 24);

this.txtEmpName.Name = "txtEmpName";

this.txtEmpName.Size = new System.Drawing.Size(96, 20);

this.txtEmpName.TabIndex = 1;

this.txtEmpName.Text = "";

//

// dataSet11

//

this.dataSet11.DataSetName = "DataSet1";

this.dataSet11.Locale = new System.Globalization.CultureInfo("en-US");

//

// txtEmpID

//

this.txtEmpID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.txtEmpID.DataBindings.Add(new System.Windows.Forms.Binding("Text",

this.dataSet11, "Employee.EmpId"));

this.txtEmpID.Location = new System.Dra wing.Point(104, 64);

this.txtEmpID.Name = "txtEmpID";

this.txtEmpID.Size = new System.Drawing.Size(96, 20);

this.txtEmpID.TabIndex = 1;

this.txtEmpID.Text = "";

//

// txtDesignation

//

this.txtDesignation.BorderStyle =

System.Windows.Forms.BorderStyle.FixedSingle;

this.txtDesignation.DataBindings.Add(new

System.Windows.Forms.Binding("Text", this.dataSet11, "Employee.Designation"));

this.txtDesignation.Location = new System.Drawing.Point(104, 104);

this.txtDesignation.Name = "txtDesignation";

this.txtDes ignation.Size = new System.Drawing.Size(96, 20);

this.txtDesignation.TabIndex = 1;

this.txtDesignation.Text = "";

//

// txtSex

//

this.txtSex.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.txtSex.DataBindings.Add(new System.Windows.Forms.Binding("Text",

this.dataSet11, "Employee.Sex"));

this.txtSex.Location = new System.Drawing.Point(104, 144);

this.txtSex.Name = "txtSex";

this.txtSex.Size = new System.Drawing.Size(96, 20);

this.txtSex.TabIndex = 1;

this.txtSex.Text = "";

//

// btnPrevious

//

this.btnPrevious.Location = new System.Drawing.Point(56, 24);

this.btnPrevious.Name = "btnPrevious";

this.btnPrevious.Size = new System.Drawing.Size(32, 23);

this.btnPrevious.TabIndex = 2;

this.btnPrevious.Text = "<";

this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);

//

// btnNext

//

this.btnNext.Location = new System.Drawing.Point(112, 24);

this.btnNext.Name = "btnNext";

this.btnNext.Size = new System.Drawing.Size(3 2, 23);

this.btnNext.TabIndex = 3;

this.btnNext.Text = ">";

this.btnNext.Click += new System.EventHandler(this.btnNext_Click);

//

// btnDelete

//

this.btnDelete.Location = new System.Drawing.Point(112, 24);

this.btnDelete.Name = "btnDelete";

this.btnDelete.Size = new System.Drawing.Size(80, 23);

this.btnDelete.TabIndex = 4;

this.btnDelete.Text = "Delete";

//

// btnInsert

//

this.btnInsert.Location = new System.Drawing.Point(8, 64);

this.btnInsert.Name = "btnInsert";

this.btnInsert.Size = new System.Drawing.Size(184, 23);

this.btnInsert.TabIndex = 5;

this.btnInsert.Text = "Insert";

//

// btnUpdate

//

this.btnUpdate.Location = new System.Drawing.Point(8, 24);

this.btnUpdate.Name = "btnUpdate";

this.btnUpdate.Size = new System.Drawing.Size(80, 23);

this.btnUpdate.TabIndex = 6;

this.btnUpdate.Text = "Update";

this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);

//

// grpSeek

//

this.grpSeek.Controls.Add(this.btnFirst);

this.grpSeek.Controls.Add(this.btnLast);

this.grpSeek.Controls.Add(this.btnNext);

this.grpSeek.Controls.Add(this.btnPrevious);

this.grpSeek.Location = new System.Drawing.Point(224, 8);

this.grpSeek.Name = "grpSeek";

this.grpSeek.Size = new System.Drawing.Size(200, 72);

this.grpSeek.TabIndex = 7;

this.grpSeek.TabStop = false;

this.grpSeek.Text = "Seek";

//

// btnFirst

//

this.btnFirs t.Location = new System.Drawing.Point(8, 24);

this.btnFirst.Name = "btnFirst";

this.btnFirst.Size = new System.Drawing.Size(32, 23);

this.btnFirst.TabIndex = 5;

this.btnFirst.Text = "|<<";

this.btnFirst.Click += new System.EventHandler(this.btnFirst_Click);

//

// btnLast

//

this.btnLast.Location = new System.Drawing.Point(160, 24);

this.btnLast.Name = "btnLast";

this.btnLast.Size = new System.Drawing.Size(32, 23);

this.btnLast.TabIndex = 4;

this.btnLast.Text = ">>|";

this.btnLast.Click += new System.EventHandler(this.btnLast_Click);

//

// grpModify

//

this.grpModify.Controls.Add(this.btnUpdate);

this.grpModify.Controls.Add(this.btnDelete);

this.grpModify.Controls.Add(this.btnInsert);

this.grpModify.Location = new System.Drawing.Point(224, 88);

this.grpModify.Name = "grpModify";

this.grpModify.Size = new System.Drawing.Size(200, 96);

this.grpModify.TabIndex = 8;

this.grpModify.TabStop = false;

this.grpModify.Text = "Modify";

//

// grpD ata

//

this.grpData.Controls.Add(this.txtSex);

this.grpData.Controls.Add(this.lblSex);

this.grpData.Controls.Add(this.txtDesignation);

this.grpData.Controls.Add(this.lblDesignation);

this.grpData.Controls.Add(this.lblEmplId);

this.grpData.Controls.Add(this.txtEmpName);

this.grpData.Controls.Add(this.txtEmpID);

this.grpData.Controls.Add(this.lblEmpName);

this.grpData.Location = new System.Drawing.Point(8, 8);

this.grpData.Name = "grpData";

this.grpData.Size = new System.Drawing.Size(208, 176);

this.grpData.TabIndex = 9;

this.grpData.TabStop = false;

this.grpData.Text = "Data";

//

// sqlDataAdapter1

//

this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;

this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;

this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;

this.sqlDataAdapter1.TableMappings.AddRange(new

System.Data.Common.DataTableMapping[] {

new System.Data.Common.DataTableMapping("Table",

"Employee", new System.Data .Common.DataColumnMapping[] {

new

System.Data.Common.DataColumnMapping("Employee", "Employee"),

new

System.Data.Common.DataColumnMapping("EmpId", "EmpId"),

new

System.Data.Common.DataColumnMapping("Sex", "Sex"),

new

System.Data.Common.DataColumnMapping("Designation" , "Designation")})});

this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;

//

// sqlDeleteCommand1

//

this.sqlDeleteCommand1.CommandText = @"DELETE FROM Employee WHERE (EmpId

= @Original_EmpId) AND (Designation = @Original_Designation OR

@Original_Designation IS NULL AND Designation IS NULL) AND (Employee =

@Original_Employee OR @Original_Employee IS NULL AND Employee IS NULL) AND

(Sex = @Original_Sex OR @Original_Sex IS NULL AND Sex IS NULL)";

this.sqlDeleteCommand1.Connection = this.sqlConnection1;

this.sqlDeleteCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Original_EmpI d",

System.Data.SqlDbType.Decimal, 9, System.Data.P arameterDirection.Input,

false, ((System.Byte)(18)), ((System.Byte)(0)), "EmpId",

System.Data.DataRowVersion.Original, null));

this.sqlDeleteCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Original_Desi gnation",

System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,

false, ((System.Byte)(0)), ((System.Byte)(0)), "Designation",

System.Data.DataRowVersion.Original, null));

this.sqlDeleteCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Original_Empl oyee",

System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,

false, ((System.Byte)(0)), ((System.Byte)(0)), "Employee",

System.Data.DataRowVersion.Original, null));

this.sqlDeleteCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Original_Sex" ,

System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input,

false, ((System.Byte)(0)), ((System.Byte)(0)), "Sex",

System.Data.DataRowVersion.Original, null));

//

// sqlConnection1

//

this.sqlConnection1.ConnectionString = "workstation

id=\"B3-AVON-HF04\";packet size=4096;user id=sa;data source=\".\";persist" +

" security info=False;initial catalog=Gokul";

//

// sqlInsertCommand1

//

this.sqlInsertCommand1.CommandText = "INSERT INTO Employee(Employee,

EmpId, Sex, Designation) VALUES (@Employee, @EmpId" +

", @Sex, @Designation); SELECT Employee, EmpId, Sex, Designation FROM

Employee WH" +

"ERE (EmpId = @EmpId)";

this.sqlInsertCommand1.Connection = this.sqlConnection1;

this.sqlInsertCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Employee",

System.Data.SqlDbType.VarChar, 50, "Employee"));

this.sqlInsertCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@EmpId", System.Data.SqlDbType.Decimal,

9, System.Data.ParameterDirection.Input, false, ((System.Byte)(18)),

((System.Byte)(0)), "EmpId", System.Data.DataRowVersion.Current, null));

this.sqlInsertCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Sex", System.Data.SqlDbType.VarChar, 10,

"Sex"));

this.sqlInsertCommand1.P arameters.Add(new

System.Data.SqlClient.SqlParameter("@Designation",

System.Data.SqlDbType.VarChar, 50, "Designation"));

//

// sqlSelectCommand1

//

this.sqlSelectCommand1.CommandText = "SELECT Employee, EmpId, Sex,

Designation FROM Employee";

this.sqlSelectCommand1.Connection = this.sqlConnection1;

//

// sqlUpdateCommand1

//

this.sqlUpdateCommand1.CommandText = @"UPDATE Employee SET Employee =

@Employee, EmpId = @EmpId, Sex = @Sex, Designation = @Designation WHERE

(EmpId = @Original_EmpId) AND (Designation = @Original_Designation OR

@Original_Designation IS NULL AND Designation IS NULL) AND (Employee =

@Original_Employee OR @Original_Employee IS NULL AND Employee IS NULL) AND

(Sex = @Original_Sex OR @Original_Sex IS NULL AND Sex IS NULL); SELECT

Employee, EmpId, Sex, Designation FROM Employee WHERE (EmpId = @EmpId)";

this.sqlUpdateCommand1.Connection = this.sqlConnection1;

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Employee",

System.Data.SqlDbType.VarChar, 50, "Employee"));

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@EmpId", System.Data.SqlDbType.Decimal,

9, System.Data.ParameterDirection.Input, false, ((System.Byte)(18)),

((System.Byte)(0)), "EmpId", System.Data.DataRowVersion.Current, null));

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Sex", System.Data.SqlDbType.VarChar, 10,

"Sex"));

this.sq lUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Designation",

System.Data.SqlDbType.VarChar, 50, "Designation"));

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Original_EmpI d",

System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input,

false, ((System.Byte)(18)), ((System.Byte)(0)), "EmpId",

System.Data.DataRowVersion.Original, null));

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Original_Desi gnation",

System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,

false, ((System.Byte)(0)), ((System.Byte)(0)), "Designation",

System.Data.DataRowVersion.Original, null));

this.sqlUpdateCommand1.Paramete rs.Add(new

System.Data.SqlClient.SqlParameter("@Original_Empl oyee",

System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,

false, ((System.Byte)(0)), ((System.Byte)(0)), "Employee",

System.Data.DataRowVersion.Original, null));

this.sqlUpdateCommand1.Parameters.Add(new

System.Data.SqlClient.SqlParameter("@Original_Sex" ,

System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input,

false, ((System.Byte)(0)), ((System.Byte)(0)), "Sex",

System.Data.DataRowVersion.Original, null));

//

// frmMain

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(432, 190);

this.Controls.Add(this.grpData);

this.Controls.Add(this.grpModify);

this.Controls.Add(this.grpSeek);

this.MaximizeBox = false;

this.MinimizeBox = false;

this.Name = "frmMain";

this.StartPosition = System.Windows.Forms.FormStar tPosition.CenterScree n;

this.Text = "Simple Data Binding";

this.Load += new System.EventHandler(this.frmMain_Load);

((System.ComponentModel.ISupportInitialize)(this.d ataSet11)).EndInit();

this.grpSeek.ResumeLayout(false);

this.grpModify.ResumeLayout(false);

this.grpData.ResumeLayout(false);

this.ResumeLayout(false);


}

#endregion


/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new frmMain ());

}


private void frmMain_Load(object sender, System.EventArgs e)

{

try

{


sqlDataAdapter1.Fill ( dataSet11,"Employee" ) ;


}


catch ( Exception Ex )

{


MessageBox.Show ( Ex.Message ) ;

}


}


private void btnNext_Click(object sender, System.EventArgs e)

{

try

{


if ( this.BindingContext[dataSet11 , "Employee" ].Position !=

this.BindingContext[dataSet11 , "Employee" ].Count - 1 )


this.BindingContext[dataSet11 , "Employee" ].Position += 1 ;


else


MessageBox.Show ( "EOF reached" ) ;


}


catch ( Exception Ex )

{


MessageBox.Show ( Ex.Message ) ;

}


return ;


}


private void btnPrevious_Click(object sender, System.EventArgs e)

{


try

{


if ( this.BindingContext[dataSet11 , "Employee" ].Position != 0 )


this.BindingContext[dataSet11 , "Employee" ].Position -= 1 ;


else


MessageBox.Show ( "EOB reached" ) ;


}


catch ( Exception Ex )

{


MessageBox.Show ( Ex.Message ) ;

}


return ;


}


private void btnFirst_Click(object sender, System.EventArgs e)

{

try

{


this.BindingContext[dataSet11 , "Employee" ].Position = 0 ;


}


catch ( Exception Ex )

{


MessageBox.Show ( Ex.Message ) ;

}


return ;

}


private void btnLast_Click(object sender, System.EventArgs e)

{

try

{


this.BindingContext[dataSet11 , "Employee" ].Position =

this.BindingContext[dataSet11 , "Employee" ].Count - 1 ;


}


catch ( Exception Ex )

{


MessageBox.Show ( Ex.Message ) ;

}


return ;

}


private void btnUpdate_Click( object sender, System.EventArgs e )

{


try

{


MessageBox.Show ( "Records Affected - " + sqlDataAdapter1.Update(

dataSet11 ).ToString ( ) ) ;


}


catch ( Exception Ex )

{


MessageBox.Show ( Ex.Message ) ;

}


return ;


}


}


}
I am struck up with a problem and want anyone here to help me out. I am a
beginner in .NET trying to learng DataBinding concepts. I have binded 4 text
boxes with a dataset but when I say adapter.update it gives me 0 records
updated! I am not getting any exceptions. Below is the complete code. Someone
please help me out.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ADO.NET
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblEmpName;
private System.Windows.Forms.Label lblEmplId;
private System.Windows.Forms.Label lblDesignation;
private System.Windows.Forms.Label lblSex;
private System.Windows.Forms.TextBox txtEmpName;
private System.Windows.Forms.TextBox txtEmpID;
private System.Windows.Forms.TextBox txtDesignation;
private System.Windows.Forms.TextBox txtSex;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.Button btnInsert;
private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.GroupBox grpSeek;
private System.Windows.Forms.GroupBox grpModify;
private System.Windows.Forms.Button btnPrevious;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnLast;
private System.Windows.Forms.Button btnFirst;
private System.Windows.Forms.GroupBox grpData;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private ADO.NET.DataSet1 dataSet11;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public frmMain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblEmpName = new System.Windows.Forms.Label();
this.lblEmplId = new System.Windows.Forms.Label();
this.lblDesignation = new System.Windows.Forms.Label();
this.lblSex = new System.Windows.Forms.Label();
this.txtEmpName = new System.Windows.Forms.TextBox();
this.dataSet11 = new ADO.NET.DataSet1();
this.txtEmpID = new System.Windows.Forms.TextBox();
this.txtDesignation = new System.Windows.Forms.TextBox();
this.txtSex = new System.Windows.Forms.TextBox();
this.btnPrevious = new System.Windows.Forms.Button();
this.btnNext = new System.Windows.Forms.Button();
this.btnDelete = new System.Windows.Forms.Button();
this.btnInsert = new System.Windows.Forms.Button();
this.btnUpdate = new System.Windows.Forms.Button();
this.grpSeek = new System.Windows.Forms.GroupBox();
this.btnFirst = new System.Windows.Forms.Button();
this.btnLast = new System.Windows.Forms.Button();
this.grpModify = new System.Windows.Forms.GroupBox();
this.grpData = new System.Windows.Forms.GroupBox();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
((System.ComponentModel.ISupportInitialize)(this.d ataSet11)).BeginInit();
this.grpSeek.SuspendLayout();
this.grpModify.SuspendLayout();
this.grpData.SuspendLayout();
this.SuspendLayout();
//
// lblEmpName
//
this.lblEmpName.AutoSize = true;
this.lblEmpName.Location = new System.Drawing.Point(8, 24);
this.lblEmpName.Name = "lblEmpName";
this.lblEmpName.Size = new System.Drawing.Size(88, 16);
this.lblEmpName.TabIndex = 0;
this.lblEmpName.Text = "Employee Name";
//
// lblEmplId
//
this.lblEmplId.AutoSize = true;
this.lblEmplId.Location = new System.Drawing.Point(8, 64);
this.lblEmplId.Name = "lblEmplId";
this.lblEmplId.Size = new System.Drawing.Size(67, 16);
this.lblEmplId.TabIndex = 0;
this.lblEmplId.Text = "Employee Id";
//
// lblDesignation
//
this.lblDesignation.AutoSize = true;
this.lblDesignation.Location = new System.Drawing.Point(8, 104);
this.lblDesignation.Name = "lblDesignation";
this.lblDesignation.Size = new System.Drawing.Size(64, 16);
this.lblDesignation.TabIndex = 0;
this.lblDesignation.Text = "Designation";
//
// lblSex
//
this.lblSex.AutoSize = true;
this.lblSex.Location = new System.Drawing.Point(8, 144);
this.lblSex.Name = "lblSex";
this.lblSex.Size = new System.Drawing.Size(24, 16);
this.lblSex.TabIndex = 0;
this.lblSex.Text = "Sex";
//
// txtEmpName
//
this.txtEmpName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtEmpName.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataSet11, "Employee.Employee"));
this.txtEmpName.Location = new System.Drawing.Point(104, 24);
this.txtEmpName.Name = "txtEmpName";
this.txtEmpName.Size = new System.Drawing.Size(96, 20);
this.txtEmpName.TabIndex = 1;
this.txtEmpName.Text = "";
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("en-US");
//
// txtEmpID
//
this.txtEmpID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtEmpID.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataSet11, "Employee.EmpId"));
this.txtEmpID.Location = new System.Drawing.Point(104, 64);
this.txtEmpID.Name = "txtEmpID";
this.txtEmpID.Size = new System.Drawing.Size(96, 20);
this.txtEmpID.TabIndex = 1;
this.txtEmpID.Text = "";
//
// txtDesignation
//
this.txtDesignation.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.txtDesignation.DataBindings.Add(new
System.Windows.Forms.Binding("Text", this.dataSet11, "Employee.Designation"));
this.txtDesignation.Location = new System.Drawing.Point(104, 104);
this.txtDesignation.Name = "txtDesignation";
this.txtDesignation.Size = new System.Drawing.Size(96, 20);
this.txtDesignation.TabIndex = 1;
this.txtDesignation.Text = "";
//
// txtSex
//
this.txtSex.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtSex.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataSet11, "Employee.Sex"));
this.txtSex.Location = new System.Drawing.Point(104, 144);
this.txtSex.Name = "txtSex";
this.txtSex.Size = new System.Drawing.Size(96, 20);
this.txtSex.TabIndex = 1;
this.txtSex.Text = "";
//
// btnPrevious
//
this.btnPrevious.Location = new System.Drawing.Point(56, 24);
this.btnPrevious.Name = "btnPrevious";
this.btnPrevious.Size = new System.Drawing.Size(32, 23);
this.btnPrevious.TabIndex = 2;
this.btnPrevious.Text = "<";
this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
//
// btnNext
//
this.btnNext.Location = new System.Drawing.Point(112, 24);
this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(32, 23);
this.btnNext.TabIndex = 3;
this.btnNext.Text = ">";
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
//
// btnDelete
//
this.btnDelete.Location = new System.Drawing.Point(112, 24);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(80, 23);
this.btnDelete.TabIndex = 4;
this.btnDelete.Text = "Delete";
//
// btnInsert
//
this.btnInsert.Location = new System.Drawing.Point(8, 64);
this.btnInsert.Name = "btnInsert";
this.btnInsert.Size = new System.Drawing.Size(184, 23);
this.btnInsert.TabIndex = 5;
this.btnInsert.Text = "Insert";
//
// btnUpdate
//
this.btnUpdate.Location = new System.Drawing.Point(8, 24);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(80, 23);
this.btnUpdate.TabIndex = 6;
this.btnUpdate.Text = "Update";
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
//
// grpSeek
//
this.grpSeek.Controls.Add(this.btnFirst);
this.grpSeek.Controls.Add(this.btnLast);
this.grpSeek.Controls.Add(this.btnNext);
this.grpSeek.Controls.Add(this.btnPrevious);
this.grpSeek.Location = new System.Drawing.Point(224, 8);
this.grpSeek.Name = "grpSeek";
this.grpSeek.Size = new System.Drawing.Size(200, 72);
this.grpSeek.TabIndex = 7;
this.grpSeek.TabStop = false;
this.grpSeek.Text = "Seek";
//
// btnFirst
//
this.btnFirst.Location = new System.Drawing.Point(8, 24);
this.btnFirst.Name = "btnFirst";
this.btnFirst.Size = new System.Drawing.Size(32, 23);
this.btnFirst.TabIndex = 5;
this.btnFirst.Text = "|<<";
this.btnFirst.Click += new System.EventHandler(this.btnFirst_Click);
//
// btnLast
//
this.btnLast.Location = new System.Drawing.Point(160, 24);
this.btnLast.Name = "btnLast";
this.btnLast.Size = new System.Drawing.Size(32, 23);
this.btnLast.TabIndex = 4;
this.btnLast.Text = ">>|";
this.btnLast.Click += new System.EventHandler(this.btnLast_Click);
//
// grpModify
//
this.grpModify.Controls.Add(this.btnUpdate);
this.grpModify.Controls.Add(this.btnDelete);
this.grpModify.Controls.Add(this.btnInsert);
this.grpModify.Location = new System.Drawing.Point(224, 88);
this.grpModify.Name = "grpModify";
this.grpModify.Size = new System.Drawing.Size(200, 96);
this.grpModify.TabIndex = 8;
this.grpModify.TabStop = false;
this.grpModify.Text = "Modify";
//
// grpData
//
this.grpData.Controls.Add(this.txtSex);
this.grpData.Controls.Add(this.lblSex);
this.grpData.Controls.Add(this.txtDesignation);
this.grpData.Controls.Add(this.lblDesignation);
this.grpData.Controls.Add(this.lblEmplId);
this.grpData.Controls.Add(this.txtEmpName);
this.grpData.Controls.Add(this.txtEmpID);
this.grpData.Controls.Add(this.lblEmpName);
this.grpData.Location = new System.Drawing.Point(8, 8);
this.grpData.Name = "grpData";
this.grpData.Size = new System.Drawing.Size(208, 176);
this.grpData.TabIndex = 9;
this.grpData.TabStop = false;
this.grpData.Text = "Data";
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new
System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table",
"Employee", new System.Data.Common.DataColumnMapping[] {
new
System.Data.Common.DataColumnMapping("Employee", "Employee"),
new
System.Data.Common.DataColumnMapping("EmpId", "EmpId"),
new
System.Data.Common.DataColumnMapping("Sex", "Sex"),
new
System.Data.Common.DataColumnMapping("Designation" , "Designation")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM Employee WHERE (EmpId
= @Original_EmpId) AND (Designation = @Original_Designation OR
@Original_Designation IS NULL AND Designation IS NULL) AND (Employee =
@Original_Employee OR @Original_Employee IS NULL AND Employee IS NULL) AND
(Sex = @Original_Sex OR @Original_Sex IS NULL AND Sex IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_EmpI d",
System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input,
false, ((System.Byte)(18)), ((System.Byte)(0)), "EmpId",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Desi gnation",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Designation",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Empl oyee",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Employee",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Sex" ,
System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Sex",
System.Data.DataRowVersion.Original, null));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation
id=\"B3-AVON-HF04\";packet size=4096;user id=sa;data source=\".\";persist" +
" security info=False;initial catalog=Gokul";
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO Employee(Employee,
EmpId, Sex, Designation) VALUES (@Employee, @EmpId" +
", @Sex, @Designation); SELECT Employee, EmpId, Sex, Designation FROM
Employee WH" +
"ERE (EmpId = @EmpId)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Employee",
System.Data.SqlDbType.VarChar, 50, "Employee"));
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@EmpId", System.Data.SqlDbType.Decimal,
9, System.Data.ParameterDirection.Input, false, ((System.Byte)(18)),
((System.Byte)(0)), "EmpId", System.Data.DataRowVersion.Current, null));
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Sex", System.Data.SqlDbType.VarChar, 10,
"Sex"));
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Designation",
System.Data.SqlDbType.VarChar, 50, "Designation"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT Employee, EmpId, Sex,
Designation FROM Employee";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE Employee SET Employee =
@Employee, EmpId = @EmpId, Sex = @Sex, Designation = @Designation WHERE
(EmpId = @Original_EmpId) AND (Designation = @Original_Designation OR
@Original_Designation IS NULL AND Designation IS NULL) AND (Employee =
@Original_Employee OR @Original_Employee IS NULL AND Employee IS NULL) AND
(Sex = @Original_Sex OR @Original_Sex IS NULL AND Sex IS NULL); SELECT
Employee, EmpId, Sex, Designation FROM Employee WHERE (EmpId = @EmpId)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Employee",
System.Data.SqlDbType.VarChar, 50, "Employee"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@EmpId", System.Data.SqlDbType.Decimal,
9, System.Data.ParameterDirection.Input, false, ((System.Byte)(18)),
((System.Byte)(0)), "EmpId", System.Data.DataRowVersion.Current, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Sex", System.Data.SqlDbType.VarChar, 10,
"Sex"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Designation",
System.Data.SqlDbType.VarChar, 50, "Designation"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_EmpI d",
System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input,
false, ((System.Byte)(18)), ((System.Byte)(0)), "EmpId",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Desi gnation",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Designation",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Empl oyee",
System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Employee",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_Sex" ,
System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "Sex",
System.Data.DataRowVersion.Original, null));
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(432, 190);
this.Controls.Add(this.grpData);
this.Controls.Add(this.grpModify);
this.Controls.Add(this.grpSeek);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n;
this.Text = "Simple Data Binding";
this.Load += new System.EventHandler(this.frmMain_Load);
((System.ComponentModel.ISupportInitialize)(this.d ataSet11)).EndInit();
this.grpSeek.ResumeLayout(false);
this.grpModify.ResumeLayout(false);
this.grpData.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmMain());
}

private void frmMain_Load(object sender, System.EventArgs e)
{
try
{

sqlDataAdapter1.Fill ( dataSet11,"Employee" ) ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

}

private void btnNext_Click(object sender, System.EventArgs e)
{
try
{

if ( this.BindingContext[dataSet11 , "Employee" ].Position !=
this.BindingContext[dataSet11 , "Employee" ].Count - 1 )

this.BindingContext[dataSet11 , "Employee" ].Position += 1 ;

else

MessageBox.Show ( "EOF reached" ) ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

return ;

}

private void btnPrevious_Click(object sender, System.EventArgs e)
{

try
{

if ( this.BindingContext[dataSet11 , "Employee" ].Position != 0 )

this.BindingContext[dataSet11 , "Employee" ].Position -= 1 ;

else

MessageBox.Show ( "EOB reached" ) ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

return ;

}

private void btnFirst_Click(object sender, System.EventArgs e)
{
try
{

this.BindingContext[dataSet11 , "Employee" ].Position = 0 ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

return ;
}

private void btnLast_Click(object sender, System.EventArgs e)
{
try
{

this.BindingContext[dataSet11 , "Employee" ].Position =
this.BindingContext[dataSet11 , "Employee" ].Count - 1 ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

return ;
}

private void btnUpdate_Click( object sender, System.EventArgs e )
{

try
{

MessageBox.Show ( "Records Affected - " + sqlDataAdapter1.Update(
dataSet11 ).ToString ( ) ) ;

}

catch ( Exception Ex )
{

MessageBox.Show ( Ex.Message ) ;
}

return ;

}

}

}


I have tried using acceptchanges but same result! I have read some where when

we use adapter.update it internally calls acceptchanges method.


When I change the text in the textbox and click next button, then back

button, it shows the text with the changes! but when i say update it is not

updating the datasource. Why is this!!!!


"Marc Vangrieken" wrote:
I have tried using acceptchanges but same result! I have read some where when
we use adapter.update it internally calls acceptchanges method.

When I change the text in the textbox and click next button, then back
button, it shows the text with the changes! but when i say update it is not
updating the datasource. Why is this!!!!

"Marc Vangrieken" wrote:
\t
\t\t\t\tHi,


I haven’’t looked at your code very thoroughly but it looks as if the

changes are not reflected in your dataset before you start the update

method of your tableAdapter. Take a look at the AcceptChanges method

on your DataSet...

http://msdn2.microsoft.com/en-us/lib...ptchanges.aspx


Kind regards,


On 25 jan, 08:39, Gokul <G...@discussions.microsoft.comwrote:
\t
Hi,

I haven''t looked at your code very thoroughly but it looks as if the
changes are not reflected in your dataset before you start the update
method of your tableAdapter. Take a look at the AcceptChanges method
on your DataSet...

http://msdn2.microsoft.com/en-us/lib...ptchanges.aspx

Kind regards,
On 25 jan, 08:39, Gokul <G...@discussions.microsoft.comwrote:
\t
\t\t\t\t I am struck up with a problem and want anyone here to help me out. I am a

beginner in .NET trying to learng DataBinding concepts. I have binded 4 text

boxes with a dataset but when I say adapter.update it gives me 0 records

updated! I am not getting any exceptions. Below is the complete code. Someone

please help me out.


using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;


namespace ADO.NET

{

/// <summary>

/// Summary description for Form1.

/// </summary>

public class frmMain : System.Windows.Forms.Form

{

private System.Windows.Forms.Label lblEmpName;

private System.Windows.Forms.Label lblEmplId;

private System.Windows.Forms.Label lblDesignation;

private System.Windows.Forms.Label lblSex;

private System.Windows.Forms.TextBox txtEmpName;

private System.Windows.Forms.TextBox txtEmpID;

private System.Windows.Forms.TextBox txtDesignation;

private System.Windows.Forms.TextBox txtSex;

private System.Windows.Forms.Button btnDelete;

private System.Windows.Forms.Button btnInsert;

private System.Windows.Forms.Button btnUpdate;

private System.Windows.Forms.GroupBox grpSeek;

private System.Windows.Forms.GroupBox grpModify;

private System.Windows.Forms.Button btnPrevious;

private System.Windows.Forms.Button btnNext;

private System.Windows.Forms.Button btnLast;

private System.Windows.Forms.Button btnFirst;

private System.Windows.Forms.GroupBox grpData;

private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;

private System.Data.SqlClient.SqlCommand sqlSelectCommand1;

private System.Data.SqlClient.SqlCommand sqlInsertCommand1;

private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;

private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;

private System.Data.SqlClient.SqlConnection sqlConnection1;

private ADO.NET.DataSet1 dataSet11;

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;


public frmMain()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();


//

// TODO: Add any constructor code after InitializeComponent call

//

}


/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}


#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.lblEmpName = new System.Windows.Forms.Label();

this.lblEmplId = new System.Windows.Forms.Label();

this.lblDesignation = new System.Windows.Forms.Label();

this.lblSex = new System.Windows.Forms.Label();

this.txtEmpName = new System.Windows.Forms.TextBox();

this.dataSet11 = new ADO.NET.DataSet1();

this.txtEmpID = new System.Wind ows.Forms.TextBox();

this.txtDesignation = new System.Windows.Forms.TextBox();

this.txtSex = new System.Windows.Forms.TextBox();

this.btnPrevious = new System.Windows.Forms.Button();

this.btnNext = new System.Windows.Forms.Button();

this.btnDelete = new System.Windows.Forms.Button();

this.btnInsert = new System.Windows.Forms.Button();

this.btnUpdate = new System.Windows.Forms.Button();

this.grpSeek = new System.Windows.Forms.GroupBox();

this.btnFirst = new System.Windows.Forms.Button();

this.btnLast = new System.Windows.Forms.Button();

this.grpModify = new System.Windows.Forms.GroupBox();
$b $b this.grpData = new System.Windows.Forms.GroupBox();

this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();

this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();

this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();

((System.ComponentModel.ISupportInitialize)(this.d ataSet11)).BeginInit();

this.grpSeek.SuspendLayout();

this.grpModify.SuspendLayout();

this.grpData.SuspendLayout();

this.SuspendLayout();

//

// lblEmpName

//

this.lblEmpName.AutoSize = true;

this.lblEmpName.Location = new System.Drawing.Point(8, 24);

this.lblEmpName.Name = "lblEmpName";

this.lblEmpName.Size = new System.Drawing.Size(88, 16);

this.lblEmpName.TabIndex = 0;

this.lblEmpName.Text = "Employee Name";

//

// lblEmplId

//

this.lblEmplId.AutoSize = true;

this.lblEmplId.Location = new System.Drawing.Point(8, 64);

this.lblEmplId.Name = "lblEmplId";

this.lblEmplId.Size = new System.Drawing.Size(67, 16);

this.lblEmplId.TabIndex = 0;

this.lblEmplId.Text = "Employee Id";

//

// lblDesignation

//

this.lblDesignation.AutoSize = true;

this.lblDesignation.Location = new System.Drawing.Point(8, 104);

this.lblDesignation.Name = "lblDesignation";

this.lblDesignation.Size = new System.Drawing.Size(64, 16);

this.lblDesignation.TabIndex = 0;

this.lblDesignation.Text = "Designation";

//

// lblSex

//

this.lblSex.AutoSize = true;

this.lblSex.Location = new System.Drawing.Point(8, 144);

this.lblSex.Name = "lblSex";

this.lblSex.Size = new System.Drawing.Size(24, 16);

this.lblSex.TabIndex = 0;

this.lblSex.Text = "Sex";

//

// txtEmpName

//

this.txtEmpName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.txtEmpName.DataBindings.Add(new System.Windows.Forms.Binding("Text",

this.dataSet11, "Employee.Employee"));

this.txtEmpName.Location = new System.Drawing.Point(104, 24);

this.txtEmpName.Name = "txtEmpName";

this.txtEmpName.Size = new System.Drawing.Size(96, 20);

this.txtEmpName.TabIndex = 1;

this.txtEmpName.Text = "";

//

// dataSet11

//

this.dataSet11.DataSetName = "DataSet1";

this.dataSet11.Locale = new System.Globalization.CultureInfo("en-US");

//

// txtEmpID

//

this.txtEmpID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.txtEmpID.DataBindings.Add(new System.Wind ows.Forms.Binding("Text",

this.dataSet11, "Employee.EmpId"));

this.txtEmpID.Location = new System.Drawing.Point(104, 64);

this.txtEmpID.Name = "txtEmpID";

this.txtEmpID.Size = new System.Drawing.Size(96, 20);

this.txtEmpID.TabIndex = 1;

this.txtEmpID.Text = "";

//

// txtDesignation

//

this.txtDesignation.BorderStyle =

System.Windows.Forms.BorderStyle.FixedSingle;

this.txtDesignation.DataBindings.Add(new

System.Windows.Forms.Binding("Text", this.dataSet11, "Employee.Designation"));

this.txtDesignation.Lo cation = new System.Drawing.Point(104, 104);

this.txtDesignation.Name = "txtDesignation";

this.txtDesignation.Size = new System.Drawing.Size(96, 20);

this.txtDesignation.TabIndex = 1;

this.txtDesignation.Text = "";

//

// txtSex

//

this.txtSex.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.txtSex.DataBindings.Add(new System.Windows.Forms.Binding("Text",

this.dataSet11, "Employee.Sex"));

this.txtSex.Location = new System.Drawing.Point(104, 144);

this.txtSex.Name = "txtSex";

this.txtSex .Size = new System.Drawing.Size(96, 20);

this.txtSex.TabIndex = 1;

this.txtSex.Text = "";

//

// btnPrevious

//

this.btnPrevious.Location = new System.Drawing.Point(56, 24);

this.btnPrevious.Name = "btnPrevious";

this.btnPrevious.Size = new System.Drawing.Size(32, 23);

this.btnPrevious.TabIndex = 2;

this.btnPrevious.Text = "<";

this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);

//

// btnNext

//

this.b tnNext.Location = new System.Drawing.Point(112, 24);

this.btnNext.Name = "btnNext";

this.btnNext.Size = new System.Drawing.Size(32, 23);

this.btnNext.TabIndex = 3;

this.btnNext.Text = ">";

this.btnNext.Click += new System.EventHandler(this.btnNext_Click);

//

// btnDelete

//

this.btnDelete.Location = new System.Drawing.Point(112, 24);

this.btnDelete.Name = "btnDelete";

this.btnDelete.Size = new System.Drawing.Size(80, 23);

this.btnDelete.TabIndex = 4;

this.btnDelete.Text = "Delete";

//

// btnInsert

//

this.btnInsert.Location = new System.Drawing.Point(8, 64);

this.btnInsert.Name = "btnInsert";

this.btnInsert.Size = new System.Drawing.Size(184, 23);

this.btnInsert.TabIndex = 5;

this.btnInsert.Text = "Insert";

//

// btnUpdate

//

this.btnUpdate.Location = new System.Drawing.Point(8, 24);

this.btnUpdate.Name = "btnUpdate";

this.btnUpdate.Size = new System.Drawing.Size(80, 23);

this.btnUpdate.TabIndex = 6;

this.btnUpdate.Text = "Update";

this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);

//

// grpSeek

//

this.grpSeek.Controls.Add(this.btnFirst);

this.grpSeek.Controls.Add(this.btnLast);

this.grpSeek.Controls.Add(this.btnNext);

this.grpSeek.Controls.Add(this.btnPrevious);

this.grpSeek.Location = new System.Drawing.Point(224, 8);

this.grpSeek.Name = "grpSeek";

this.grpSeek.Size = new System.Drawing.Size(200, 72);

this.grpSeek.TabIndex = 7;

this.grpSeek.TabStop = false;

this.grpSeek.Text = "Seek";

//

// btnFirst

//

this.btnFirst.Location = new System.Drawing.Point(8, 24);

this.btnFirst.Name = "btnFirst";

this.btnFirst.Size = new System.Drawing.Size(32, 23);

this.btnFirst.TabIndex = 5;

this.btnFirst.Text = "|<<";

this.btnFirst.Click += new System.EventHandler(this.btnFirst_Click);

//

// btnLast

//

this.btnLast.Location = new System.Drawing.Point(160, 24);

this.btnLast.Name = &quo t;btnLast";

this.btnLast.Size = new System.Drawing.Size(32, 23);

this.btnLast.TabIndex = 4;

this.btnLast.Text = ">>|";

this.btnLast.Click += new System.EventHandler(this.btnLast_Click);

//

// grpModify

//

this.grpModify.Controls.Add(this.btnUpdate);

this.grpModify.Controls.Add(this.btnDelete);

this.grpModify.Controls.Add(this.btnInsert);

this.grpModify.Location = new System.Drawing.Point(224, 88);

this.grpModify.Name = "grpModify";

this.grpModify.Size = new System.Drawing.Size(200, 96);
$b$ b this.grpModify.TabIndex = 8;

this.grpModify.TabStop = false;

this.grpModify.Text = "Modify";

//
I am struck up with a problem and want anyone here to help me out. I am a
beginner in .NET trying to learng DataBinding concepts. I have binded 4 text
boxes with a dataset but when I say adapter.update it gives me 0 records
updated! I am not getting any exceptions. Below is the complete code. Someone
please help me out.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ADO.NET
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblEmpName;
private System.Windows.Forms.Label lblEmplId;
private System.Windows.Forms.Label lblDesignation;
private System.Windows.Forms.Label lblSex;
private System.Windows.Forms.TextBox txtEmpName;
private System.Windows.Forms.TextBox txtEmpID;
private System.Windows.Forms.TextBox txtDesignation;
private System.Windows.Forms.TextBox txtSex;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.Button btnInsert;
private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.GroupBox grpSeek;
private System.Windows.Forms.GroupBox grpModify;
private System.Windows.Forms.Button btnPrevious;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnLast;
private System.Windows.Forms.Button btnFirst;
private System.Windows.Forms.GroupBox grpData;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private ADO.NET.DataSet1 dataSet11;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public frmMain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblEmpName = new System.Windows.Forms.Label();
this.lblEmplId = new System.Windows.Forms.Label();
this.lblDesignation = new System.Windows.Forms.Label();
this.lblSex = new System.Windows.Forms.Label();
this.txtEmpName = new System.Windows.Forms.TextBox();
this.dataSet11 = new ADO.NET.DataSet1();
this.txtEmpID = new System.Windows.Forms.TextBox();
this.txtDesignation = new System.Windows.Forms.TextBox();
this.txtSex = new System.Windows.Forms.TextBox();
this.btnPrevious = new System.Windows.Forms.Button();
this.btnNext = new System.Windows.Forms.Button();
this.btnDelete = new System.Windows.Forms.Button();
this.btnInsert = new System.Windows.Forms.Button();
this.btnUpdate = new System.Windows.Forms.Button();
this.grpSeek = new System.Windows.Forms.GroupBox();
this.btnFirst = new System.Windows.Forms.Button();
this.btnLast = new System.Windows.Forms.Button();
this.grpModify = new System.Windows.Forms.GroupBox();
this.grpData = new System.Windows.Forms.GroupBox();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
((System.ComponentModel.ISupportInitialize)(this.d ataSet11)).BeginInit();
this.grpSeek.SuspendLayout();
this.grpModify.SuspendLayout();
this.grpData.SuspendLayout();
this.SuspendLayout();
//
// lblEmpName
//
this.lblEmpName.AutoSize = true;
this.lblEmpName.Location = new System.Drawing.Point(8, 24);
this.lblEmpName.Name = "lblEmpName";
this.lblEmpName.Size = new System.Drawing.Size(88, 16);
this.lblEmpName.TabIndex = 0;
this.lblEmpName.Text = "Employee Name";
//
// lblEmplId
//
this.lblEmplId.AutoSize = true;
this.lblEmplId.Location = new System.Drawing.Point(8, 64);
this.lblEmplId.Name = "lblEmplId";
this.lblEmplId.Size = new System.Drawing.Size(67, 16);
this.lblEmplId.TabIndex = 0;
this.lblEmplId.Text = "Employee Id";
//
// lblDesignation
//
this.lblDesignation.AutoSize = true;
this.lblDesignation.Location = new System.Drawing.Point(8, 104);
this.lblDesignation.Name = "lblDesignation";
this.lblDesignation.Size = new System.Drawing.Size(64, 16);
this.lblDesignation.TabIndex = 0;
this.lblDesignation.Text = "Designation";
//
// lblSex
//
this.lblSex.AutoSize = true;
this.lblSex.Location = new System.Drawing.Point(8, 144);
this.lblSex.Name = "lblSex";
this.lblSex.Size = new System.Drawing.Size(24, 16);
this.lblSex.TabIndex = 0;
this.lblSex.Text = "Sex";
//
// txtEmpName
//
this.txtEmpName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtEmpName.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataSet11, "Employee.Employee"));
this.txtEmpName.Location = new System.Drawing.Point(104, 24);
this.txtEmpName.Name = "txtEmpName";
this.txtEmpName.Size = new System.Drawing.Size(96, 20);
this.txtEmpName.TabIndex = 1;
this.txtEmpName.Text = "";
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("en-US");
//
// txtEmpID
//
this.txtEmpID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtEmpID.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataSet11, "Employee.EmpId"));
this.txtEmpID.Location = new System.Drawing.Point(104, 64);
this.txtEmpID.Name = "txtEmpID";
this.txtEmpID.Size = new System.Drawing.Size(96, 20);
this.txtEmpID.TabIndex = 1;
this.txtEmpID.Text = "";
//
// txtDesignation
//
this.txtDesignation.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle;
this.txtDesignation.DataBindings.Add(new
System.Windows.Forms.Binding("Text", this.dataSet11, "Employee.Designation"));
this.txtDesignation.Location = new System.Drawing.Point(104, 104);
this.txtDesignation.Name = "txtDesignation";
this.txtDesignation.Size = new System.Drawing.Size(96, 20);
this.txtDesignation.TabIndex = 1;
this.txtDesignation.Text = "";
//
// txtSex
//
this.txtSex.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtSex.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataSet11, "Employee.Sex"));
this.txtSex.Location = new System.Drawing.Point(104, 144);
this.txtSex.Name = "txtSex";
this.txtSex.Size = new System.Drawing.Size(96, 20);
this.txtSex.TabIndex = 1;
this.txtSex.Text = "";
//
// btnPrevious
//
this.btnPrevious.Location = new System.Drawing.Point(56, 24);
this.btnPrevious.Name = "btnPrevious";
this.btnPrevious.Size = new System.Drawing.Size(32, 23);
this.btnPrevious.TabIndex = 2;
this.btnPrevious.Text = "<";
this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
//
// btnNext
//
this.btnNext.Location = new System.Drawing.Point(112, 24);
this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(32, 23);
this.btnNext.TabIndex = 3;
this.btnNext.Text = ">";
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
//
// btnDelete
//
this.btnDelete.Location = new System.Drawing.Point(112, 24);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(80, 23);
this.btnDelete.TabIndex = 4;
this.btnDelete.Text = "Delete";
//
// btnInsert
//
this.btnInsert.Location = new System.Drawing.Point(8, 64);
this.btnInsert.Name = "btnInsert";
this.btnInsert.Size = new System.Drawing.Size(184, 23);
this.btnInsert.TabIndex = 5;
this.btnInsert.Text = "Insert";
//
// btnUpdate
//
this.btnUpdate.Location = new System.Drawing.Point(8, 24);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(80, 23);
this.btnUpdate.TabIndex = 6;
this.btnUpdate.Text = "Update";
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
//
// grpSeek
//
this.grpSeek.Controls.Add(this.btnFirst);
this.grpSeek.Controls.Add(this.btnLast);
this.grpSeek.Controls.Add(this.btnNext);
this.grpSeek.Controls.Add(this.btnPrevious);
this.grpSeek.Location = new System.Drawing.Point(224, 8);
this.grpSeek.Name = "grpSeek";
this.grpSeek.Size = new System.Drawing.Size(200, 72);
this.grpSeek.TabIndex = 7;
this.grpSeek.TabStop = false;
this.grpSeek.Text = "Seek";
//
// btnFirst
//
this.btnFirst.Location = new System.Drawing.Point(8, 24);
this.btnFirst.Name = "btnFirst";
this.btnFirst.Size = new System.Drawing.Size(32, 23);
this.btnFirst.TabIndex = 5;
this.btnFirst.Text = "|<<";
this.btnFirst.Click += new System.EventHandler(this.btnFirst_Click);
//
// btnLast
//
this.btnLast.Location = new System.Drawing.Point(160, 24);
this.btnLast.Name = "btnLast";
this.btnLast.Size = new System.Drawing.Size(32, 23);
this.btnLast.TabIndex = 4;
this.btnLast.Text = ">>|";
this.btnLast.Click += new System.EventHandler(this.btnLast_Click);
//
// grpModify
//
this.grpModify.Controls.Add(this.btnUpdate);
this.grpModify.Controls.Add(this.btnDelete);
this.grpModify.Controls.Add(this.btnInsert);
this.grpModify.Location = new System.Drawing.Point(224, 88);
this.grpModify.Name = "grpModify";
this.grpModify.Size = new System.Drawing.Size(200, 96);
this.grpModify.TabIndex = 8;
this.grpModify.TabStop = false;
this.grpModify.Text = "Modify";
//


Hi,


I’’ve been struggeling with this myself once, i now remeber that you

don’’t have to call AcceptChanges at all. Indeed it gets called

automatically after the update (Don’’t call it before updating like I

suggested because this will have the averse effect).
Hi,

I''ve been struggeling with this myself once, i now remeber that you
don''t have to call AcceptChanges at all. Indeed it gets called
automatically after the update (Don''t call it before updating like I
suggested because this will have the averse effect).
\t
\t\t\t\t>When I change the text in the textbox and click next button, then back
button, it shows the text with the changes! but when i say update it is not
updating the datasource. Why is this!!!!
>When I change the text in the textbox and click next button, then back
button, it shows the text with the changes! but when i say update it is not
updating the datasource. Why is this!!!!



Where is your database? Is it an .MDF file that’’s in you Visual Studio

Project ? If that’’s the case, check if VS isn’’t copying it to the

output directory every time you run the application. See
http://forums.microsoft.com/MSDN/Sho...27451&SiteID=1.

This was the cause of the "problem" i had a while ago.


Kind regards,


On 25 jan, 12:08, Gokul <G...@discussions.microsoft.comwrote:
\t

Where is your database? Is it an .MDF file that''s in you Visual Studio
Project ? If that''s the case, check if VS isn''t copying it to the
output directory every time you run the application. See
http://forums.microsoft.com/MSDN/Sho...27451&SiteID=1.
This was the cause of the "problem" i had a while ago.

Kind regards,

On 25 jan, 12:08, Gokul <G...@discussions.microsoft.comwrote:

\t
\t\t\t\tI have tried using acceptchanges but same result! I have read some where when

we use adapter.update it internally calls acceptchanges method.


When I change the text in the textbox and click next button, then back

button, it shows the text with the changes! but when i say update it is not

updating the datasource. Why is this!!!!


"Marc Vangrieken" wrote:
\t
I have tried using acceptchanges but same result! I have read some where when
we use adapter.update it internally calls acceptchanges method.

When I change the text in the textbox and click next button, then back
button, it shows the text with the changes! but when i say update it is not
updating the datasource. Why is this!!!!

"Marc Vangrieken" wrote:
\t
\t\t\t\t Hi,
Hi,

\t
\t\t\t\t I haven’’t looked at your code very thoroughly but it looks as if the

changes are not reflected in your dataset before you start the update

method of your tableAdapter. Take a look at the AcceptChanges method

on your DataSet...
I haven''t looked at your code very thoroughly but it looks as if the
changes are not reflected in your dataset before you start the update
method of your tableAdapter. Take a look at the AcceptChanges method
on your DataSet...

http://msdn2.microsoft.com/en-us/lib...taset.acceptch...
http://msdn2.microsoft.com/en-us/lib...taset.acceptch...

\t
\t\t\t\t Kind regards,
Kind regards,

\t
\t\t\t\t On 25 jan, 08:39, Gokul <G...@discussions.microsoft.comwrote:
\t
On 25 jan, 08:39, Gokul <G...@discussions.microsoft.comwrote:
\t
\t\t\t\t I am struck up with a problem and want anyone here to help me out. I am a

beginner in .NET trying to learng DataBinding concepts. I have binded4 text

boxes with a dataset but when I say adapter.update it gives me 0 records

updated! I am not getting any exceptions. Below is the complete code.Someone

please help me out.
I am struck up with a problem and want anyone here to help me out. I am a
beginner in .NET trying to learng DataBinding concepts. I have binded4 text
boxes with a dataset but when I say adapter.update it gives me 0 records
updated! I am not getting any exceptions. Below is the complete code.Someone
please help me out.

\t
\t\t\t\t using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

\t
\t\t\t\t namespace ADO.NET

{

/// <summary>

/// Summary description for Form1.

/// </summary>

public class frmMain : System.Windows.Forms.Form

{

private System.Windows.Forms.Label lblEmpName;

private System.Windows.Forms.Label lblEmplId;

private System.Windows.Forms.Label lblDesignation;

private System.Windows.Forms.Label lblSex;

private System.Windows.Forms.TextBox txtEmpName;

private System.Windows.Forms.TextBox txtEmpID;

private System.Windows.Forms.TextBox txtDesignation;

private System.Windows.Forms.TextBox txtSex;

private System.Windows.Forms.Button btnDelete;

private System.Windows.Forms.Button btnInsert;

private System.Windows.Forms.Button btnUpdate;

private System.Windows.Forms.GroupBox grpSeek;

private System.Windows.Forms.GroupBox grpModify;

private System.Windows.Forms.Button btnPrevious;

private System.Windows.Forms.Button btnNext;

private System.Windows.Forms.Button btnLast;

private System.Windows.Forms.Button btnFirst;

private System.Windows.Forms.GroupBox grpData;

private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;

private System.Data.SqlClient.SqlCommand sqlSelectCommand1;

private System.Data.SqlClient.SqlCommand sqlInsertCommand1;

private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;

private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;

private System.Data.SqlClient.SqlConnection sqlConnection1;

private ADO.NET.DataSet1 dataSet11;

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;
namespace ADO.NET
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblEmpName;
private System.Windows.Forms.Label lblEmplId;
private System.Windows.Forms.Label lblDesignation;
private System.Windows.Forms.Label lblSex;
private System.Windows.Forms.TextBox txtEmpName;
private System.Windows.Forms.TextBox txtEmpID;
private System.Windows.Forms.TextBox txtDesignation;
private System.Windows.Forms.TextBox txtSex;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.Button btnInsert;
private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.GroupBox grpSeek;
private System.Windows.Forms.GroupBox grpModify;
private System.Windows.Forms.Button btnPrevious;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnLast;
private System.Windows.Forms.Button btnFirst;
private System.Windows.Forms.GroupBox grpData;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private ADO.NET.DataSet1 dataSet11;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

\t
\t\t\t\t public frmMain()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();
public frmMain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

\t
\t\t\t\t //

// TODO: Add any constructor code after InitializeComponent call

//

}
//
// TODO: Add any constructor code after InitializeComponent call
//
}

\t
\t\t\t\t /// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

\t
\t\t\t\t #region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.lblEmpName = new System.Windows.Forms.Label();

this.lblEmplId = new System.Windows.Forms.Label();

this.lblDesignation = new System.Windows.Forms.Label();

this.lblSex = new System.Windows.Form s.Label();

this.txtEmpName = new System.Windows.Forms.TextBox();

this.dataSet11 = new ADO.NET.DataSet1();

this.txtEmpID = new System.Windows.Forms.TextBox();

this.txtDesignation = new System.Windows.Forms.TextBox();

this.txtSex = new System.Windows.Forms.TextBox();

this.btnPrevious = new System.Windows.Forms..Button();

this.btnNext = new System.Windows.Forms.Button();

this.btnDelete = new System.Windows.Forms.Button();

this.btnInsert = new System.Windows.Forms.Button();

this.btnUpdate = new System.Windows.Forms.Button();

this.grpSeek = new System.Windows.Forms.GroupBox();

this.btnFirst = new System.Windows.Forms.Button();

this.btnLast = new System.Windows.Forms.Button();

this.grpModify = new System.Windows.Forms.GroupBox();

this.grpData = new System.Windows.Forms.GroupBox();

this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();

this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();

this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();

((System.ComponentModel.ISuppo rtInitialize)(this.d ataSet11)).BeginInit();

this.grpSeek.SuspendLayout();

this.grpModify.SuspendLayout();

this.grpData.SuspendLayout();

this.SuspendLayout();

//

// lblEmpName

//

this.lblEmpName.AutoSize = true;

this.lblEmpName.Location = new System.Drawing.Point(8, 24);

this.lblEmpName.Name = "lblEmpName";

this.lblEmpName.Size = new System.Drawing.Size(88, 16);

this.lblEmpName.TabIndex = 0;

this.lblEmpName.Text = "Employee Name";

//

/ / lblEmplId

//

this.lblEmplId.AutoSize = true;

this.lblEmplId.Location = new System.Drawing.Point(8, 64);

this.lblEmplId.Name = "lblEmplId";

this.lblEmplId.Size = new System.Drawing.Size(67, 16);

this.lblEmplId.TabIndex = 0;

this.lblEmplId.Text = "Employee Id";

//

// lblDesignation

//

this.lblDesignation.AutoSize = true;

this.lblDesignation.Location = new System.Drawing.Point(8, 104);

this.lblDesignation.Name = "lblDesignation";

this.lblDesignation.Size = new Sy stem.Drawing.Size(64, 16);

this.lblDesignation.TabIndex = 0;

this.lblDesignation.Text = "Designation";

//

// lblSex

//

this.lblSex.AutoSize = true;

this.lblSex.Location = new System.Drawing.Point(8, 144);

this.lblSex.Name = "lblSex";

this.lblSex.Size = new System.Drawing.Size(24, 16);

this.lblSex.TabIndex = 0;

this.lblSex.Text = "Sex";

//

// txtEmpName

//

this.txtEmpName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSing le;

this.txtEmpName.DataBindings.Add(new System.Windows.Forms.Binding("Text",

this.dataSet11, "Employee.Employee"));

this.txtEmpName.Location = new System.Drawing.Point(104, 24);

this.txtEmpName.Name = "txtEmpName";

this.txtEmpName.Size = new System.Drawing.Size(96, 20);

this.txtEmpName.TabIndex = 1;...
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblEmpName = new System.Windows.Forms.Label();
this.lblEmplId = new System.Windows.Forms.Label();
this.lblDesignation = new System.Windows.Forms.Label();
this.lblSex = new System.Windows.Forms.Label();
this.txtEmpName = new System.Windows.Forms.TextBox();
this.dataSet11 = new ADO.NET.DataSet1();
this.txtEmpID = new System.Windows.Forms.TextBox();
this.txtDesignation = new System.Windows.Forms.TextBox();
this.txtSex = new System.Windows.Forms.TextBox();
this.btnPrevious = new System.Windows.Forms..Button();
this.btnNext = new System.Windows.Forms.Button();
this.btnDelete = new System.Windows.Forms.Button();
this.btnInsert = new System.Windows.Forms.Button();
this.btnUpdate = new System.Windows.Forms.Button();
this.grpSeek = new System.Windows.Forms.GroupBox();
this.btnFirst = new System.Windows.Forms.Button();
this.btnLast = new System.Windows.Forms.Button();
this.grpModify = new System.Windows.Forms.GroupBox();
this.grpData = new System.Windows.Forms.GroupBox();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
((System.ComponentModel.ISupportInitialize)(this.d ataSet11)).BeginInit();
this.grpSeek.SuspendLayout();
this.grpModify.SuspendLayout();
this.grpData.SuspendLayout();
this.SuspendLayout();
//
// lblEmpName
//
this.lblEmpName.AutoSize = true;
this.lblEmpName.Location = new System.Drawing.Point(8, 24);
this.lblEmpName.Name = "lblEmpName";
this.lblEmpName.Size = new System.Drawing.Size(88, 16);
this.lblEmpName.TabIndex = 0;
this.lblEmpName.Text = "Employee Name";
//
// lblEmplId
//
this.lblEmplId.AutoSize = true;
this.lblEmplId.Location = new System.Drawing.Point(8, 64);
this.lblEmplId.Name = "lblEmplId";
this.lblEmplId.Size = new System.Drawing.Size(67, 16);
this.lblEmplId.TabIndex = 0;
this.lblEmplId.Text = "Employee Id";
//
// lblDesignation
//
this.lblDesignation.AutoSize = true;
this.lblDesignation.Location = new System.Drawing.Point(8, 104);
this.lblDesignation.Name = "lblDesignation";
this.lblDesignation.Size = new System.Drawing.Size(64, 16);
this.lblDesignation.TabIndex = 0;
this.lblDesignation.Text = "Designation";
//
// lblSex
//
this.lblSex.AutoSize = true;
this.lblSex.Location = new System.Drawing.Point(8, 144);
this.lblSex.Name = "lblSex";
this.lblSex.Size = new System.Drawing.Size(24, 16);
this.lblSex.TabIndex = 0;
this.lblSex.Text = "Sex";
//
// txtEmpName
//
this.txtEmpName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtEmpName.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataSet11, "Employee.Employee"));
this.txtEmpName.Location = new System.Drawing.Point(104, 24);
this.txtEmpName.Name = "txtEmpName";
this.txtEmpName.Size = new System.Drawing.Size(96, 20);
this.txtEmpName.TabIndex = 1;...



meer lezen ?

meer lezen ?


这篇关于数据绑定问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆