473,726 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to save data (easy way)


i have a data grid (i fill when i run the program) then the user insert rows
and i wana save..

i used SqlClient.SqlCo mmandBuilder but it fail, just save 1 recordr, some
times 2 records, sometimes no one record

in the past (my old job) i do it easy whit Delphi or C but i don't find the
easy way to do this in a easy way.

can you help me?
Nov 21 '05 #1
2 1380

It is hard to answer this question when you do not describe something more
when it does not save it and when it does.

Mostly is it because that the data is saved in the datasource when there is
a rowchange done in the datagrid.

That you can force by using the method endcurrentedit

Something as
BindingContext( ds.Tables(0)).E ndCurrentEdit()

where in this sampel ds.tables(0) stands for your datasource

I hope this helps?


"tnks" <tn**@discussio ns.microsoft.co m>

i have a data grid (i fill when i run the program) then the user insert
and i wana save..

i used SqlClient.SqlCo mmandBuilder but it fail, just save 1 recordr, some
times 2 records, sometimes no one record

in the past (my old job) i do it easy whit Delphi or C but i don't find
easy way to do this in a easy way.

can you help me?

Nov 21 '05 #2
Tnks Cor...

(sorry for my english)
dim sqlcon as new sqlconnection(c onectionstring)
Dim Sqladapt As new SqlDataAdapter( "select * from oc_header", sqlcon)
Dim dsOC As New DataSet
Dim dt As New DataTable
Sqladapt.Fill(d sOC, "Compras")
dt = dsOC.Tables("Co mpras")
DgResumen.DataS ource = dsOC.Tables("Co mpras") 'dgresumen is a data grid

'this works fine.. but the user insert some rows into the datagrid, then
when the user finish, press the "save" button..

in the save button have this code.

Dim command_builder As SqlClient.SqlCo mmandBuilder
If dsOC.HasChanges Then
command_builder = New SqlClient.SqlCo mmandBuilder(sq ladapt)
sqladapt.Update (dsOC, "Compras")
Catch ex As System.Exceptio n
MessageBox.Show (ex.ToString)
Catch exSQl As SqlClient.SqlEx ception
MessageBox.Show (exSQl.ToString )
End Try
End If

but don't save all the new records (rows) added some times the user add 3
rows and the save procedure just save 1 or 2, i know i'am new in vb net, and
really dont know what i'am doing wrong.

tnks for your help
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or less complex technical calculations, several input variables. I would like to equipp the starting panel with the usual New, Open, Save, Save As, Close etc. menus (like in Excel, or Word, etc.) What is the best way to accomplish Save, or Save As?...
by: Rolf Hemmerling | last post by:
Hello ! Beginner's question: What ist the easiest way to store and save objects in a file generated by a C++ program, by using the "standard C++ library" and/or "Standard Template Library ( STL )" ? So I would like to generate some objects ( of different classes ) with a C++ program and would like to make it permanent / persistent, so that
by: John J. Hughes II | last post by:
I need to save a DWORD to the sql server, the below posts an error, any suggestions on what I am doing wrong. I have the column in the sql server defined as an int since unsigned int is not valid. Also trying to avoid setting it to a bigint in the server. Casting an int to an uint use to work in C++. System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection(...); cn.Open()
by: Scott M. Lyon | last post by:
I'm working on a WinForm application, and recently was informed that I need to create an "Export" function for the data (stored in SQL Server), in a specific (TXT, tab delimited) format. I'd like to figure out a way to bring up the "Open or Save" dialog similar to what we see on Web Pages, but with a minimal amount of coding (especially considering this isn't a Web application), but would then allow me to create a TXT file and either...
by: Henok Girma | last post by:
Hello Gurus, I want to save the state of an unbound DataGridView on my Windows Form application to an XML file so i can later load it back.. Basically, on my form I have a DataGridView, it's got some DataGridViewTextBoxCell, DataGridViewComboBoxCell etc, i want to export all that to XML.. Any help is greatly appreciated.
by: John | last post by:
I have a Win app in C#. I want to save the data the user enterere into textboxes and the selections the user made to comboboxes when the user close the app. So next time when the user launches the app, he can see the data he entered before. How can I do this? Thanks.
by: greg_e | last post by:
Is there a way to create a form in a local html file where the contents of the form are written to a local file when a 'save' button is selected? It would be nice if it was as easy as changing "somesite.com" to "file:///C:/whatever" and "post" to "save"... in the following form: <form action = "somesite.com" method="post"> <p<textarea name="Text" rows="20" cols="80"</textarea> <input value="Send" type="submit"><input type="reset"</p>...
by: KC-Mass | last post by:
I have a form that is used to ID and then load Excel files into Access. I use labels on the form to record which file was last loaded. That was accomplished with a simple lblFileLoaded = strFullFileName. The label would show the file name and when the form was closed and then opened it would still show the name of the last file loaded. That preserves an important piece of information. Suddenly the form has stopped doing that. When you...
by: jehugaleahsa | last post by:
Hello: We are running into an issue. Whenever our users save using either the save key or a BindingNavigator, whatever control is in focus won't be updated. Our users are getting confused when they are asked whether they want to save their changes. Is there a way to force the the control changes to be accepted prior to saving? Is there an easy way to add this to all of our code?
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.