How to initialise data bound fields for entry of a new record

  • Thread starter Thread starter Joshua Ellul
  • Start date Start date
J

Joshua Ellul

Hi There,

Could someone tell me how I could initialise my dataset for entry of a new
record, so that the data bound text boxes would be cleared?

Josh
 
I've tried the following w/o success:

Me.BindingContext(myDS, "Persons").AddNew()
 
Well, on the surface it looks like all is well. Can you post the Binding
code?
 
Setup and Binding is done as follows:

Dim SqlStr As String = "SELECT * FROM Persons"

myCon = New OleDb.OleDbConnection(DBStr)
myAdapter = New OleDb.OleDbDataAdapter(SqlStr, myCon)
myAdapter.Fill(myDS, "Persons")

Dim myBuilder As New OleDb.OleDbCommandBuilder(myAdapter)
myAdapter.UpdateCommand = myBuilder.GetUpdateCommand
myAdapter.InsertCommand = myBuilder.GetInsertCommand
myAdapter.DeleteCommand = myBuilder.GetDeleteCommand
myCon.Close()

txtFirstName.DataBindings.Add("text", myDS, "Persons.FirstName")


Then to create a new record:
Me.BindingContext(myDS, "Persons").AddNew()

Any ideas?

Josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top