473,597 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataSet insert problem

I've a dataGrid set up (the standard msdn example) with a
SqlDataAdapter, and DataSet.

The problem is that after inserting a new row using the
LinkButton1_Cli ck() (code below)
then edit the values
I then try to update the values using "DataGrid1_Upda teCommand()"
The FindByApplID does't find the row.
It looks like the 'DataSet12.Appl .Rows.InsertAt( dr, 0)' doesn't insert.
But it show up in the grid.

The msdn example is

But add new row is added.
''''''''''''''' '''''''''''''''
Private Sub LinkButton1_Cli ck(ByVal sender As System.Object,
ByVal e As
System.EventArg s) Handles LinkButton1.Cli ck

Dim dr As DataRow = DataSet12.Appl. NewRow()
dr.Item("Descri ption") = "Enter Description here"
DataSet12.Appl. Rows.InsertAt(d r, 0)

''' The inserts into a table using a indentity field as primary

''' SqlDataAdapter1 insert command
'''' INSERT INTO Appl(Descriptio n, Wav)
''' VALUES (@Description, @Wav); SELECT ApplID,
''' Description, Wav FROM Appliance

Dim Index As Integer = dr.Item("ApplID ") ''' Does get a new
identity value back

'' I must not be committing/binding/something here

DataGrid1.EditI temIndex = 0
DataGrid1.DataB ind()
End Sub

''''''''''''''' ''''''''''''''' ''''''
Private Sub DataGrid1_Updat eCommand(ByVal source As Object,
ByVal e
As System.Web.UI.W ebControls.Data GridCommandEven tArgs)
Handles DataGrid1.Updat eCommand

Dim key As String = DataGrid1.DataK eys(e.Item.Item Index).ToString ()
Dim desc, watts As String
Dim tb As TextBox
tb = CType(e.Item.Ce lls(1).Controls (0), TextBox)
desc = tb.Text
If desc <"Enter Description here" And desc.Trim.Lengt h 0 Then
tb = CType(e.Item.Ce lls(2).Controls (0), TextBox)
If tb.Text.Trim.Le ngth <0 And IsNumeric(tb.Te xt.Trim) Then
watts = tb.Text
Dim r As DataSet1.Applia nceRow

r = DataSet12.Appli ance.FindByAppl ianceID(key) '
*********** not found

r.Description = desc
r.Watts = watts
SqlDataAdapter1 .Update(DataSet 12)
DataGrid1.EditI temIndex = -1
DataGrid1.DataB ind()
End If
End If

End Sub

Thanks in advance

Aug 8 '06 #1
0 1114

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

Similar topics

by: Steve Donnor | last post by:
Here's my question.. I have a Dataset which has populated a datagrid with information from an AS400 That SQL looks like this "Select MASYS, MAFLD, MADATA, MAEQV from QS36F.MAPDATA WHERE MASYS = ? AND MAFLD = ? It populates a data adapter in which at that point I open a new dataset and I have the parameters and such setup including the proper update, insert and delete commands created as well. It works great I can update and insert and...
by: Zachary Hilbun | last post by:
The below is some test code to help me learn how to update a dataset. It is supposed to read the value of UserCounter and write it back. The UserCounter is being read correctly as 0, is 1 when written back, but is not being written back to the database. Although I've used a foreach loop there is actually only 1 record in the dataset. I'm going to eventually use transactions but have commented them out for now
by: Henry | last post by:
Hi. I've been trying to modify my dataset and have been unsucessful. Any help would be great. What I have is a dataset in a session variable. Here is what I have done to stored into the dataset via store procedure. Sample Stored Procedure: CREATE PROCEDURE prcGetData AS
by: JIM.H. | last post by:
Hello, Can I send a dataset as a parameter into stored procedure and import data to a table in the stored procedure? Thanks, Jim.
by: jay | last post by:
I am using the dataset object to add a row to a sql server database in vb.net code, as follows: dim drow as DataRow dim cmdBld as new SqlCommandBuilder(mySqlDataAdapter) ds.tables(0).NewRow() drow("field1") = data for field 1 and so forth ds.tables(0).rows.add(drow) cmdBld = New SqlCommandBuilder(mySqlDataAdapter)
by: Bishoy George | last post by:
I have a dataset called ds1 filled with 2 tables Employees and Customers from Northwind database. I have dropdownList called ddLastName with the following properties: ddLastName.DataSource = ds1; ddLastName.DataMember = "Employees"; ddLastName.DataTextField = "LastName"; ddLastName.DataBind(); ddLastName.Items.Insert(0,"Select:");
by: Graham Blandford | last post by:
Hi all, Would someone be able to tell me the most 'graceful' way of removing unwanted rows from a dataset based on a condition prior to update? OR, resetting the rows all to unchanged after they are initally added to the recordset. I create a dataset, which begins empty after the initial .Fill. Then I create several rows with some default information, leaving one
by: Ramakrishnan Nagarajan | last post by:
Hi, I am converting Excel data into a Dataset in C#. There are around 24 columns in the Excel Sheet. First I tried to insert one row with correct values in the Excel sheet. i.e. for text columns I entered text values and for numeric columns I entered numeric values. It works fine and pass through all the validation checks and gets inserted into the database successfully. But when I gave some junk values in the excel sheet and tried to...
by: Mr Newbie | last post by:
HI People, Thanks to all who helped me earlier on the subject of @@IDentity. However, I seem to have hit another snagette! My DataSet contains two tables from the SQL Server. lets say Master and Details. The way I have it set up is that a relationship exists in the DataSet between the two to force referential integrety etc. I am now able to a master record in the master table and add records to the
by: Peter Van Wilrijk | last post by:
Hi, In VB6 I used a method requery to repopulate a recordset. I don't find an equivalent for the .NET dataset. I don't update my datasets at all, but I use them to navigate through subsets of my tables, saying my dataset contains primary keys, ordered in a specific way. When I go the next, previous, first or last record in the dataset I execute a select stored procedure. When I do an insert, delete or update I call a stored...
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: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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.