I believe you will need a CommandBuilders object on your data adapter to
push the data back to your table.
>From the help...
DataAdapter..::.Update Method
Public Function CreateCommandAndUpdate( _
ByVal connectionString As String, _
ByVal queryString As String) As DataSet
Dim dataSet As DataSet = New DataSet
Using connection As New OleDbConnection(connectionString)
connection.Open()
Dim adapter As New OleDbDataAdapter()
adapter.SelectCommand = New OleDbCommand( _
queryString, connection)
Dim builder As OleDbCommandBuilder = _
New OleDbCommandBuilder(adapter)
adapter.Fill(dataSet)
' Code to modify the data in the DataSet here.
' Without the OleDbCommandBuilder this line would fail.
builder.GetUpdateCommand()
adapter.Update(dataSet)
End Using
Return dataSet
End Function
On Thu, Aug 5, 2010 at 12:50 PM, KeidrickP <[email protected]> wrote:
> you don't have an update statement is a start
> what condition(s) are you wanting to update the table on?
> I would also recommend using a stored procedure rather than an inline
> select/update statement.
>
>
>
> On Thu, Aug 5, 2010 at 11:45 AM, Markei54545 <[email protected]>wrote:
>
>> I have done the following code to update a SQL database. It reads the
>> data fine but try as I might I can't get it to update the database. It
>> just doesn't do anything, no errors.
>>
>> Any ideas? Any help gratefully received.
>>
>> Dim ConnString2 As String
>> Dim SQLString2 As String
>>
>> ConnString2 = "Driver={SQL
>>
>> Server};Server=SC000511\SQLEXPRESSR2;Trusted_Connection=Yes;Database=Belvoir;"
>>
>> SQLString2 = "SELECT * FROM stockItem "
>>
>> Dim cn2 As New Data.Odbc.OdbcConnection(ConnString2)
>> Dim cmd2 As New Data.Odbc.OdbcCommand(SQLString2, cn2)
>> Dim da2 As New Data.Odbc.OdbcDataAdapter(cmd2)
>> Dim ds2 As New Data.DataSet
>> da2.Fill(ds2)
>>
>> Dim dr2 As DataRow
>>
>> For Each dr2 In ds2.Tables(0).Rows
>>
>> dr2("Name") = "TEST"
>>
>> Next
>> ds2.Tables(0).AcceptChanges()
>
>
>
>
>
>