DataGridView and SQL Server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?TmV0dGFu?=

    #1

    DataGridView and SQL Server

    Hi

    I have a datagridview that is filled with data from Sql Server, and this
    works fine. But I will be able to make changes in the datagridview that is
    saved in the database.

    My code:
    Sub FillGridTest(SQ L as string, connString as string)
    Dim sqlConn As New SqlConnection(c onnString)
    sqlConn.Open()
    Dim sqlDAP As SqlDataAdapter = New SqlDataAdapter( SQL, sqlConn)
    Dim dsWaitingImport s As DataSet = New DataSet("Import s")
    sqlDAP.Fill(dsW aitingImports, "Imports")
    dataGrid.DataSo urce = dsWaitingImport s.Tables("Impor ts")
    sqlConn.Close()
    End Sub

    for the update I have tried:
    If Not dsWaitingImport s.Tables("tblIm port_Spec").Get Changes Is Nothing Then
    sqlDAP.Update(d sWaitingImports .Tables("Import s").GetChang es)
    End If
    But I got this error:
    Update requires a valid UpdateCommand when passed DataRow collection with
    modified rows

    Anyone than can help me?

    Thanks/ Nettan
Working...