Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Database from DataGrid

Status
Not open for further replies.

WelshyWizard

IS-IT--Management
Apr 23, 2006
89
GB
Hi all,

I am using the following code to fill a datagrid with the contents of a csv file.

Code:
        If OpenFileDialog1.ShowDialog(Me) = DialogResult.OK Then
            Dim fi As New FileInfo(OpenFileDialog1.FileName)
            Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Text;Data Source=" & fi.DirectoryName
            Dim objConn As New OleDbConnection(sConnectionString)
            objConn.Open()
            Dim objCmdSelect As New OleDbCommand("SELECT * FROM " & fi.Name, objConn)
            Dim objAdapter1 As New OleDbDataAdapter
            objAdapter1.SelectCommand = objCmdSelect
            Dim objDataset1 As New DataSet
            objAdapter1.Fill(objDataset1, "test")
            DataGrid1.DataSource = objDataset1.Tables(0).DefaultView
            objConn.Close()
        End If

What I then want to do, after the user has made the relevant changes, is to press a button that will update a database with the information held in the datagrid.
I am not using a dataset so am a bit lost! Any help would be much appreciated.

Cheers.

Today is the tomorrow you worried about yesterday - and all is well.....
 
Sorry... I don't want to update, I want to INSERT! The table will be empty.

Today is the tomorrow you worried about yesterday - and all is well.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top