473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

DataBinding & Update

13
Hi people,
I'm a newbie in C# Development.

I have a problem with these lines of code:

...
SqlConnection c = new SqlConnection(MainForm.connection);
c.Open();
SqlCommand cmd = new SqlCommand("SELECT id, ragione_sociale, indirizzo, cap, cittą, provincia FROM cliente", c);
c.Close();
da = new SqlDataAdapter(cmd);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
ds = new DataSet();da.Fill(ds,"cliente");

// textBox
txtId.DataBindings.Add("Text",ds,"cliente.id");
txtRagione_sociale.DataBindings.Add("Text",ds,"cli ente.ragione_sociale");
}

// Simple button SAVE in the form
void Button1Click(object sender, EventArgs e)
{
da.Update(ds, "cliente");
this.Close();
}


Why this lines doesn't update database after modify textBox???
I've used Update command in many parts of my application and it works fine (i.e. DataGridView).

Thank you!!!
Jul 10 '07 #1
3 1054
havana7
13
BindingContext[ds, "cliente"].EndCurrentEdit();
Jul 10 '07 #2
kenobewan
4,871 Expert 4TB
Welcome to TSDN. The problem may be that your update occurs in an event unrelated to your command function. HTH.
Jul 10 '07 #3
havana7
13
Thank you very much but I've solved my problem with this line:
BindingContext[ds, "cliente"].EndCurrentEdit();
Jul 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Richard | last post by:
Hi, I'm having issues with DataBinding. I have a Form with two data bound comboboxes on it. When you select something in one combobox I may {or may not} want to change the selected item in the...
1
by: Vik | last post by:
Concatenation operator & used in the databinding expressions for the datagrid template columns appears as '&' in HTML. It causes an error when opening the pages. I have to replace '&' by '&' each...
2
by: louise raisbeck | last post by:
Hi, There seem to be several ways to update rows in sql. What is the best practice? I have written a medium sized update statement into a stored procedure, taking values from the web text...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
1
by: thzero | last post by:
Is there any way to do this without using the ObjectDataSource? (Apologies for the long post) I have a simple data object: public class TestDO { public TestDO() {} public ID { get; set; }...
3
by: virlinz | last post by:
Hello I'm a newbie who has a problem with updating the dataset into the database. Maybe I missed a few lines of codes. Please shed some light for me. The following code is working but not like I...
5
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
2
by: mikeachamberlain | last post by:
Hi. I have an <asp:Imagecontrol in which I am databinding the ImageURL attribute. The URL is another ASPX page that provides the binary source of the image, The problem is that ASP.NET is...
7
by: Vlado Jasovic | last post by:
Hello, I'm using typed dataset for databinding to windows controls and I'm having some problems. I'm trying to move all business logic to datatable column_changing events and the problem that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.