|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Updating Data from a dataGriddata, 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 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.. 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?
Multiple fields in a single textbox
Image Resource - not released Sending an Email from .net? Translate Visual C++ to VB.NET Closing all forms at once How to import always the FIRST available sheet from EXCEL-File Vb.Net 2003 Quirks dot.net com class function How to create a new sheet in EXCEL-File via OLEDBProvider Inherent encryption in .NET 2.0? |
|||||||||||||||||||||||