473,385 Members | 1,582 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,385 software developers and data experts.

Updating Data from a dataGrid

Hey, I have never used a datagrid/dataset/adaptor/table method for updating
data, I have always used direct updates to the database so ADO is quite new
to me.

I have a datagrid and I change a value in one of the fields.
I hit save and the following code runs...

Dim da As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("Select *
from MISRE_Threshold", cn)
da.Update(dsThreshold, "MISRE_Threshold")
my code to populate the datagrid is as below, what am i missing to actually
update the data in the database......

Private Sub Thresholds_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

UserName.Text = dbProps.MyUserName
Password.Text = dbProps.MyPassword
Database.Text = dbProps.MyDatabase
Server.Text = dbProps.MyServer

Try
cn = New SqlClient.SqlConnection("user id=" & UserName.Text &
";password=" & Password.Text & ";database=" & Database.Text & ";server=" &
Server.Text)
cn.Open()
cmdSelect.Connection = cn

Dim da As SqlClient.SqlDataAdapter = New
SqlClient.SqlDataAdapter("Select * from MISRE_Threshold", cn)
'Dim dsThreshold As DataSet = New DataSet

' fill dataset
da.Fill(dsThreshold, "MISRE_Threshold")

'Attach DataSet to DataGrid
dgThreshold.DataSource = dsThreshold.DefaultViewManager
Dim dt As New DataTable
dt.CaseSensitive = False
dt = dsThreshold.Tables("MISRE_Threshold")

Catch ex As Exception
MessageBox.Show("Error: Could not establish database connection")
End Try

End Sub
May 12 '06 #1
2 1305
rj
hi,

i dont know about your code, but if you're using visual studio 2002 or
later, you can use the data form wizard. this will add the buttons to
your form and all you have to do is sort out the layout.
To go there click 'new item' > select dataform wizard and follow the
wizard.
Its a really easy way of doing simple data forms.

hope it helps..

May 12 '06 #2
Thanks but I am trying to write code that will update the dataset (and
database) with any changes the user makes to the datagrid. I tried the
DataAdaptor configuration wizard but it doesn't work.

How do I overcome this issue?

May 12 '06 #3

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

Similar topics

0
by: cwbp17 | last post by:
Have two tables that have a FK relationship on ID column. Have one datagrid that displays all of the columns of both tables. What's the best approach on updating a row from the datagrid back to...
3
by: Jon Agiato | last post by:
Hi, I am trying to use a data grid in a web application in which I have three tiers. The DataGrid is not set up to a data source, or a data adapter, so everytime I make a change I send the cell...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
9
by: A P | last post by:
Hi! I have created a sample datagrid that can update data on a database. Please help me solve the problem, I have attached both aspx and code behind (aspx.vb): ______________________ ...
1
by: Geraldine Hobley | last post by:
hello, I have put thisup b4, but I think that people have misunderstood the problem, so I will make it clearer. I have a problem updating a dataset that is bound to a datagrid. The code that I...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
2
by: Greg | last post by:
I'm using the Framework 1.1, so I don't have access to the new DataGridView object. What I'm wondering is, is there a really simple way to bind a plain datagrid to a database in such a way that...
2
by: toddw607 | last post by:
Hi Everyone! I have a ASP.NET webform that brings data in from SQL Server 2000 and displays it on a page. I want to update the webpage while in IE using the following code: <%@ Import...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
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
Oralloy
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,...
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...

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.