1. Imports System.Data.SqlClient
2.
3.
4. Public Class Form1
5. Inherits System.Windows.Forms.Form
6.
7. Private conexion As SqlConnection
8. Private dataSet As DataSet
9. Private dataAdapter As SqlDataAdapter
10. Private bs As BindingSource
11.
12. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
13. Dim conexion As New SqlConnection
14. conexion.ConnectionString = "Data Source=.SQLEXPRESS;AttachDbFilename=C:" & _
15. "UsersMaxiAppDataLocalTemporary ProjectsPruebasDatabase1.mdf;Integrated Security=True;User Instance=True"
16.
17. Dim dataAdapter As New SqlDataAdapter("SELECT * From Clientes", conexion)
18. Dim CB As SqlCommandBuilder = New SqlCommandBuilder(dataAdapter)
19.
20. Dim dataSet As New DataSet
21. dataAdapter.Fill(dataSet, "Clientes")
22.
23. Me.DataGridView1.DataSource = dataSet
24. Me.DataGridView1.DataMember = "Clientes"
25.
26. End Sub
27.
28. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
29. Dim fila As DataRow
30. fila = Me.dataSet.Tables("Clientes").NewRow()
31. fila("Nombre") = TextBox1.Text
32. fila("Apellido") = TextBox2.Text
33. Me.dataSet.Tables("Clientes").Rows.Add(fila)
34. End Sub
35.
36. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
37. Me.dataAdapter.Update(Me.dataSet, "Clientes")
38. End Sub
39. End Class
40.
Ya vi tu burrada
jajjaja.. y perdona que te lo diga pero es una burrada
jajjajajajajajaja.. mira tu linea 8.. y mira tu linea 20..
8. Private dataSet As DataSet
20. Dim dataSet As New DataSet
estas declarando 2 veces la misma variable, una en el Load y otra variable Global, la que tu llenas es la que esta dentro del Load, lo que debiste hacer es lo siguiente:
Cambiar tu linea 20 por esto -----> dataSet = New DataSet()
y ya..
... debe funcar.
.. saludos.