Click here to Skip to main content
15,909,651 members
Home / Discussions / C#
   

C#

 
AnswerRe: numeric validation Pin
stancrm16-Aug-06 19:30
stancrm16-Aug-06 19:30 
AnswerRe: numeric validation Pin
Christian Graus16-Aug-06 19:33
protectorChristian Graus16-Aug-06 19:33 
Questiona Question regarding object serialization Pin
Green Fuze16-Aug-06 19:15
Green Fuze16-Aug-06 19:15 
AnswerRe: a Question regarding object serialization Pin
coolestCoder16-Aug-06 20:55
coolestCoder16-Aug-06 20:55 
GeneralRe: a Question regarding object serialization Pin
Green Fuze16-Aug-06 21:19
Green Fuze16-Aug-06 21:19 
QuestionHow do I update Dataset to Datasource?. Pin
nguyenquang028416-Aug-06 19:01
nguyenquang028416-Aug-06 19:01 
AnswerRe: How do I update Dataset to Datasource?. Pin
Tamimi - Code16-Aug-06 19:13
Tamimi - Code16-Aug-06 19:13 
GeneralRe: How do I update Dataset to Datasource?. Pin
nguyenquang028416-Aug-06 19:57
nguyenquang028416-Aug-06 19:57 
Thanh you very much.
Today i have a example so that I am very your help.
My Code is very dirty.Sniff | :^)
But I will send you.
Step1. I create A class ClsLogin in a file : "lsLogin.cs"
<br />
 public class ClsLogin<br />
	{<br />
	   public string userName;<br />
	   public string passWord;<br />
	   public static SqlDataAdapter SQLDataAdapter;<br />
	   public static DataSet ODataSet;<br />
	   public SqlCommand sqlcom;<br />
	   public SqlCommandBuilder sqlBuilder;<br />
           }<br />

Step 2.I Create a Class User in a file: "ClsUser.cs"
<br />
 public class ClsUser<br />
	{<br />
		public ClsUser()<br />
		{}<br />
		public DataSet FillUser()<br />
		{<br />
			ClsLogin oClogin  = new ClsLogin();<br />
			ClsLogin.SQLDataAdapter = new SqlDataAdapter("SELECT * FROM tbl_Employee",ClsConnection.SQLConnection);<br />
			ClsLogin.ODataSet = new DataSet();<br />
			try<br />
			{<br />
				ClsLogin.SQLDataAdapter.Fill(ClsLogin.ODataSet,"User");<br />
				<br />
				oClogin.SQLCOMBUILDER =new SqlCommandBuilder(ClsLogin.SQLDataAdapter);<br />
				ClsLogin.SQLDataAdapter.Update(ClsLogin.ODataSet.Tables[0]);<br />
				return ClsLogin.ODataSet ;<br />
<br />
			}<br />
			catch(Exception ex)<br />
			{<br />
				throw ex;<br />
				return ClsLogin.ODataSet;<br />
			}<br />
		}<br />
	}<br />

Step3. i binding data to Datagrid in my form in file: "MyWindfor.cs"
<br />
               private void btnLoad_Click(object sender, System.EventArgs e)<br />
		{<br />
			this.CheckLoad();<br />
		}<br />
		private CurrencyManager oCm;<br />
                private DataSet oDs;<br />
		private void CheckLoad()<br />
		{<br />
			<br />
			ClsUser oUser =new ClsUser();<br />
			try<br />
			{<br />
				oDs = oUser.FillUser();<br />
				this.dataGrid1.DataSource = oDs.Tables["User"];<br />
				this.oCm = (CurrencyManager)BindingContext[oDs.Tables[0]];<br />
			}<br />
			catch(Exception ex)<br />
			{<br />
				MessageBox.Show("Lỗi sảy ra: " +ex.Message +":"+ex.Source);<br />
			}<br />
		}<br />

. Finish to Here is Success. Data in DataBase displayed in Datagrid if click btnLoad.
***** But my Problem is:*****
I have a button : name = btnDelete in file "MyWindform.cs". And I writed code to delete a row in dataset, after I want update dataset to "Database" As.
<br />
private void btnDelete_Click(object sender, System.EventArgs e)<br />
	{<br />
                	   ClsLogin.ODataSet.Tables[0].Rows.RemoveAt(this.oCm.Position);<br />
								ClsLogin oLogin =new ClsLogin();<br />
<br />
oLogin.sqlBuilder= new SqlCommandBuilder(ClsLogin.SQLDataAdapter);<br />
						  ClsLogin.SQLDataAdapter.Update(ClsLogin.ODataSet.Tables[0]);<br />
			<br />
}<br />

Then you Click btnDelete: a Row in table of Dataset deleted. But Data Datasource don't Update. Didn't change.

Help Me. D'Oh! | :doh:
GeneralRe: How do I update Dataset to Datasource?. Pin
Tamimi - Code16-Aug-06 20:16
Tamimi - Code16-Aug-06 20:16 
AnswerRe: How do I update Dataset to Datasource?. Pin
nguyenquang028416-Aug-06 21:48
nguyenquang028416-Aug-06 21:48 
QuestionFlickering displaying image in Panel control Pin
kozu16-Aug-06 16:36
kozu16-Aug-06 16:36 
AnswerRe: Flickering displaying image in Panel control Pin
Christian Graus16-Aug-06 17:07
protectorChristian Graus16-Aug-06 17:07 
GeneralRe: Flickering displaying image in Panel control Pin
kozu17-Aug-06 10:54
kozu17-Aug-06 10:54 
GeneralRe: Flickering displaying image in Panel control Pin
Christian Graus17-Aug-06 11:22
protectorChristian Graus17-Aug-06 11:22 
GeneralRe: Flickering displaying image in Panel control Pin
kozu17-Aug-06 11:29
kozu17-Aug-06 11:29 
GeneralRe: Flickering displaying image in Panel control Pin
kozu18-Aug-06 12:40
kozu18-Aug-06 12:40 
QuestionSerial number Pin
omar el halwagy16-Aug-06 15:06
omar el halwagy16-Aug-06 15:06 
AnswerRe: Serial number Pin
bob1697216-Aug-06 16:06
bob1697216-Aug-06 16:06 
AnswerRe: Serial number Pin
Christian Graus16-Aug-06 16:26
protectorChristian Graus16-Aug-06 16:26 
AnswerRe: Serial number [modified] Pin
Divyang Mithaiwala16-Aug-06 19:50
Divyang Mithaiwala16-Aug-06 19:50 
QuestionGetting info from computer Pin
TheJudeDude16-Aug-06 14:16
TheJudeDude16-Aug-06 14:16 
AnswerRe: Getting info from computer Pin
Christian Graus16-Aug-06 16:27
protectorChristian Graus16-Aug-06 16:27 
GeneralRe: Getting info from computer Pin
TheJudeDude16-Aug-06 16:51
TheJudeDude16-Aug-06 16:51 
GeneralRe: Getting info from computer Pin
Christian Graus16-Aug-06 16:58
protectorChristian Graus16-Aug-06 16:58 
GeneralRe: Getting info from computer [modified] Pin
TheJudeDude16-Aug-06 17:33
TheJudeDude16-Aug-06 17:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.