Missing DataBind Method For DataGrid

It seems that do an update from the datagrid back to the datbase I need the .DataBind method for the DataGird.  This option does not appear in my VB.Net 2003???  The closest I have is .DataBindings but it appears not to be the same function?

Any help would be greatly appreciated.  I am trying to add a DataSet to an existing DataGrid and DataSet, and then update the database.  Shown below is what I have but does not alter the database in any way.

        connectionstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ProjectFolder & "\" & ProjectName & "\points.mdb"

        Dim dfins As New DataSet

        Dim confin As OleDb.OleDbConnection = New OleDb.OleDbConnection(connectionstr)

        Dim dafin As New OleDb.OleDbDataAdapter("select * from CoordList", confin)


        MainDataGrid.DataSource = ds1.Tables(0)

        Dim cm As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(dafin)

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If this is a windows app, then there is no databind for the datagrid because it isn't necessary, databind is only for web apps.

where is the above code located because if this is in the same sub, of course your database isn't updated because you haven't made any changes to it.
tosheaAuthor Commented:
What I am trying to accomplish is this.  I have an Access database established.  I want to read in a comma delimited file and populate the existing database.  I am trying to do this by creating a datagrid with the imported comma delimted file on a form.  On another form I have a datagrid populated with the database.  Now I would like to transfer the comma delimted datagrid to my database.  I seem to be struggling with this.  Shown below is the code to first populate the imported file datagrid, followed by the code to import the database file datagrid.  I can get these two datagrids populated with this code.  However, I cannot get the two datagrids into my database.  Any thoughts?

' Comma Delimited Datagrid On Form1

        Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
                  & "Data Source=" & strFilePath & ";" & "Extended Properties=""text;HDR=NO;FMT=Delimited"""

                Dim conn As New OleDb.OleDbConnection(strConnectionString)
                conn.Open() ' Open connection with the database.

                Dim objCmdSelect As New OleDb.OleDbCommand("SELECT * FROM [" & strFileName & "]", conn) ' Create new OleDbCommand to return data from worksheet.
                'Dim objCmdSelect As New OleDb.OleDbCommand("Select * from [Sheet1$]", conn) ' Create new OleDbCommand to return data from worksheet.

                ' Create new OleDbDataAdapter used to build a DataSet based on the preceding SQL SELECT statement.
                objAdapter = New OleDb.OleDbDataAdapter

                'Pass the Select command to the adapter.
                objAdapter.SelectCommand = objCmdSelect

                'Create new DataSet to hold information from the worksheet.
                objDataSet = New DataSet

                'Fill the DataSet with the information from the file.
                objAdapter.Fill(objDataSet, "CoordList")

                ' Create Primary Key
                Dim myTable As DataTable = New DataTable
                Dim keys(1) As DataColumn
                Dim myColumn As DataColumn

                ' Create column one.
                myColumn = New DataColumn
                myColumn.DataType = System.Type.GetType("System.String")
                myColumn.ColumnName = "Point"

                ' Add the column to the DataTable Columns collection.

                ' Add the column to the array.
                keys(0) = myColumn
                ' End Create Primary Key

                ' Create TableSet
                objTableSet = New DataGridTableStyle
                objTableSet.MappingName = objDataSet.Tables(0).ToString

                objDataSet.Tables(0).Columns(0).ColumnName = "Point"
                objDataSet.Tables(0).Columns(1).ColumnName = "Northing"
                objDataSet.Tables(0).Columns(2).ColumnName = "Easting"
                objDataSet.Tables(0).Columns(3).ColumnName = "Elevation"
                objDataSet.Tables(0).Columns(4).ColumnName = "Description"
                objDataSet.Tables(0).Columns(5).ColumnName = "Layer"
                objDataSet.Tables(0).Columns(6).ColumnName = "Method"
                objDataSet.Tables(0).Columns(7).ColumnName = "Notes"

                Dim TC0 As New DataGridTextBoxColumn
                TC0.MappingName = objDataSet.Tables(0).Columns(0).ColumnName
                TC0.HeaderText = "Point"
                TC0.Width = 80
                TC0.TextBox.MaxLength = 10

                Dim TC1 As New DataGridTextBoxColumn
                TC1.MappingName = objDataSet.Tables(0).Columns(1).ColumnName
                TC1.HeaderText = "Northing"
                TC1.Width = 80
                TC1.TextBox.MaxLength = 30

                Dim TC2 As New DataGridTextBoxColumn
                TC2.MappingName = objDataSet.Tables(0).Columns(2).ColumnName
                TC2.HeaderText = "Easting"
                TC2.Width = 80
                TC2.TextBox.MaxLength = 30

                Dim TC3 As New DataGridTextBoxColumn
                TC3.MappingName = objDataSet.Tables(0).Columns(3).ColumnName
                TC3.HeaderText = "Elevation"
                TC3.Width = 80
                TC3.TextBox.MaxLength = 30

                Dim TC4 As New DataGridTextBoxColumn
                TC4.MappingName = objDataSet.Tables(0).Columns(4).ColumnName
                TC4.HeaderText = "Description"
                TC4.Width = 120
                TC4.TextBox.MaxLength = 50

                Dim TC5 As New DataGridTextBoxColumn
                TC5.MappingName = objDataSet.Tables(0).Columns(5).ColumnName
                TC5.HeaderText = "Layer"
                TC5.Width = 120
                TC5.TextBox.MaxLength = 50

                Dim TC6 As New DataGridTextBoxColumn
                TC6.MappingName = objDataSet.Tables(0).Columns(6).ColumnName
                TC6.HeaderText = "Method"
                TC6.Width = 120
                TC6.TextBox.MaxLength = 50

                Dim TC7 As New DataGridTextBoxColumn
                TC7.MappingName = objDataSet.Tables(0).Columns(7).ColumnName
                TC7.HeaderText = "Notes"
                TC7.Width = 200
                TC7.TextBox.MaxLength = 200

                ' Add The TableStyle To The Datagrid

                'Build a table from the original data.
                ImportedGrid.DataSource = objDataSet.Tables(0).DefaultView

                'Clean up objects.

' Database Datagrid On Form2

        Dim connectionstr As String
        Dim mysql As String

        connectionstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ProjectFolder & "\" & ProjectName & "\points.mdb"

        Dim dfins As New DataSet

        Dim confin As OleDb.OleDbConnection = New OleDb.OleDbConnection(connectionstr)

        Dim dafin As New OleDb.OleDbDataAdapter("select * from CoordList", confin)


        DataGrid1.DataSource = objDataSet.Tables(0)

        Dim cm As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(dafin)


' To Merge Datagrids And To Write The Database
' Button On Form2

        Dim myConnection As OleDbConnection
        Dim mysql As String

        myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ProjectFolder & "\" & ProjectName & "\points.mdb")

        Dim connectionstr As String


        mysql = "SELECT * FROM CoordList"

        Dim da As New OleDbDataAdapter(mysql, daConnection)

        Dim ds As New DataSet("CoordList")

        ' Map Table to CoordList
        da.TableMappings.Add("Table", "CoordList")

        da.Fill(ds, "CoordList")



        Import_Grid.DataGrid1.DataSource = ds.Tables("CoordList").DefaultView


        GoTo bypass

Hi toshea,

If you just want to add the delimited file to your database, there is a much simpler way to do this.

Is there a special reason you want to use a datagrid to accomplish this ?
tosheaAuthor Commented:
There was at one point, to cross check grids and warn of duplicates and request action.  At this point I would rather just have the data transfered right to the database.  I would appreciate your method of accomplishing this.
here is an example (this works I tested it) this ofcourse only works if the text file and the table have the same structure.
the trick is to update the target dataset with the dataset that you filled with the text file

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim strfilepath As String = "c:\"
            Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
                     & "Data Source=" & strFilePath & ";" & "Extended Properties=""text;HDR=NO;FMT=Delimited"""

            Dim conn As New OleDb.OleDbConnection(strConnectionString)

            Dim objCmdSelect As New OleDb.OleDbCommand("SELECT * FROM [test.txt]", conn)

            objadapter = New OleDb.OleDbDataAdapter

            objadapter.SelectCommand = objCmdSelect

            objdataset = New DataSet

            objadapter.AcceptChangesDuringFill = False
            objdataset.Tables(0).Columns(0).ColumnName = "tt1"
            objdataset.Tables(0).Columns(1).ColumnName = "tt2"
            objdataset.Tables(0).TableName = "ttt"

            targetDS = New DataSet

        Catch ex As Exception
        End Try
    End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.