How can insert and update datagrid in VB.net Application

Jan 10 2009 5:44 AM
How can insert and update datagrid in VB.net Application?

I have tried using this code for my vb.net application. It compiles with no errors but it does not update the database. I want to be able to update all the columns in the database when all the fields have been filled. Here is the code I placed. I will try to post a screenshot in case you might need one.

Thank You

Imports System
Imports System.Data
Imports System.Data.SqlClient

Public Class Form1

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

        Me.GameTableAdapter.Fill(Me.DataSet1.Game)

    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Show()
    End Sub
End Class
Public Class MainClass

    Shared Sub Main()
        Dim MyDS As DataSet = New DataSet()
        Dim Connection As SqlConnection = New SqlConnection( _
           "Server=(local)\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI")
        Connection.Open()

        Dim MyDA As SqlDataAdapter = New SqlDataAdapter( _
               "SELECT * FROM [Bowl] OD", Connection)
        Dim myBuilder As SqlCommandBuilder = New SqlCommandBuilder(MyDA)

        Console.WriteLine(myBuilder.GetUpdateCommand().CommandText)
    End Sub
End Class

Answers (1)