Reputation: 148
I can see the DataGridView changes fine but the Form's controls don't update.
From what I can tell the bs.ResetBindings(False)
should trigger the update!
I've tried binding the controls from the property bindings tab as well with same result!
However I must confess this my first attempt at vb.net!
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
testdatTableAdapter.Fill(DATAHUBDataSet.testdat)
bs = New BindingSource
address.DataBindings.Add("text", bs, "address")
typep.DataBindings.Add("text", bs, "type_projet")
env.DataBindings.Add("text", bs, "enveloppe")
ra.DataBindings.Add("text", bs, "region")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'If Not IsNothing(ds.Tables("testdat")) Then
' ds.Tables.Clear()
'End If
da = Nothing
ds = Nothing
qry = "Select * from work.testdat where network = "
qry &= "'" & resstrb.Text & "'"
con.Close()
con.Open()
'qry = "Select * from work.testdat"
cmd = New SqlCommand(qry, con)
da = New SqlDataAdapter(cmd)
ds = New DataSet
da.Fill(ds, "testdat")
DataGridView1.DataSource = ds.Tables("testdat")
bs.ResetBindings(False)
End Sub
End class
Imports System.Data.SqlClient
'! note to mod, can't get this last bit of code to work with ctrl K
Module test_sqldata
Public str As String = getconstring()
Public con As New SqlConnection(str)
Public cmd As SqlCommand
Public da As SqlDataAdapter
Public ds As DataSet
Public bs As BindingSource
Public qry As String
Public Function getconstring() As String
Return "Data Source=XXXXXXX\YYYYYYYY;Initial Catalog=DATAHUB;Integrated Security=True"
End Function
End Module
Upvotes: 0
Views: 65
Reputation: 827
Either bind your 'bs' to the ds.datatable or remove the 'bs' and bind your textboxs to 'ds.Tables("testdat")' If you look you can clearly see that the grid and textboxs are using 2 differnt datasources, the bindingsource datasource is not being set at all so the textboxs are bound to an empty bindingsource
Upvotes: 1