Cor,
I put the
dim cmb as new OleDb.OleDbCommandbuilder(da)
line in as you suggested. Still got the same error. Can you explain the
other command you described and where it goes? I don't understand.
Thanks,
Gary
"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:OW%(E-Mail Removed)...
> Gary,
>
> There is a lot still not right, however let us first take this problem.
> Your error message is strange for me, that I don't directly see.
> However you needs an update command in the dataadapter.
> That is easy to do for a simple select statement as you have.
> See the code I have pasted inline (one row)
> And try than again. I now don't understand the error you get, however that
> is at least needed.
>
> When you have it running have than a look at
> Databinding
> \\\
> cma = DirectCast(BindingContext(dataset1.Tables(0)), CurrencyManager)
> textbox1.DataBindings.Add(New Binding("Text", dataset1.Tables(0),
> "LastName"))
> ///
> The cma.position gives you than the row that is used and you can affect
> that by using buttons on your form.
>
> I hope this helps,
>
> Cor
>
>> Public Class Form1
>>
>> Inherits System.Windows.Forms.Form
>> Public cn As OleDb.OleDbConnection
>> Public ds As DataSet
>> Public da As OleDb.OleDbDataAdapter
>> Public rowEmployee As DataRow
>>
>> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles MyBase.Load
>>
>> Try
>> Dim strConn As String
>> strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
>> Source=C:\adonetsbs\SampleDBs\nwind.mdb;"
>>
>> Dim cn As New OleDb.OleDbConnection(strConn)
>>
>> Dim strSQL As String
>> strSQL = "SELECT EmployeeID, FirstName, LastName, Address,
>> City, Region, " & _
>> "PostalCode from Employees ORDER BY LastName, FirstName"
>>
>> Dim da = New OleDb.OleDbDataAdapter(strSQL, strConn)
>> Dim ds As New DataSet
>>
>> da.Fill(ds, "Employees")
>
> dim cmb as new OleDb.OleDbCommandbuilder(da)
>
>> Dim tbl As DataTable = ds.Tables(0)
>>
>> 'rowEmployee = New DataRow
>> rowEmployee = tbl.Rows(0)
>> txtFirstName.Text = rowEmployee("FirstName")
>> txtLastName.Text = rowEmployee("LastName")
>> txtAddress.Text = rowEmployee("Address")
>>
>> Catch ex As Exception
>> MessageBox.Show(ex.Message & " :: " & ex.Source)
>> Finally
>> End Try
>> End Sub
>>
>> Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles btnUpdate.Click
>> Try
>> rowEmployee("LastName") = txtLastName.Text
>> da.Update(ds)
>>
>> Catch ex As Exception
>>
>> MessageBox.Show(ex.Message & " :: " & ex.Source)
>>
>> End Try
>>
>> End Sub
>> End Class
>> ---------------------------------------
>>
>> When it runs I get the following error:
>>
>> "Object reference not set to an instance of an object."
>>
>> on the da.Update(ds) line in the btnUpdate_Click
>> routine.
>>
>> HELP.
>>
>> Thanks,
>>
>> Gary
>>
>>
>
>
|