Data binding textbox problems

  • Thread starter Lori Markle via .NET 247
  • Start date
L

Lori Markle via .NET 247

Hi, I already posted this but can't find it anywhere!

I'm having a problem that seems very simple. I'm trying to updatea db and am getting stuck on the data binding of a textbox. Iget a "Cannot bind to property or column permitnumber onDataSource" OR if I use ("text", ds, "permits.permitnumber")nothing happens except that a permit number that already existsshows up in the textbox. Do I have something in the wrong order?HEre is my code:

Dim dbConn As NewOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Projects\Tests\ParkingPErmits.mdb")
Dim da As New OleDbDataAdapter("select * from permits",dbConn)
Dim cb As New OleDbCommandBuilder(da)
Dim ds As New DataSet

da.UpdateCommand = cb.GetUpdateCommand
da.DeleteCommand = cb.GetDeleteCommand
da.InsertCommand = cb.GetInsertCommand
da.Fill(ds, "permits")

txtPermits.DataBindings.Clear()
txtPermits.DataBindings.Add(New Binding("text", ds,"permitnumber"))

da.Update(ds, "permits")

Thanks!
 
W

William Ryan eMVP

use the second syntax that you mention ("permits.permitnumber") and call
EndCurrentEdit before you call Update.
Hi, I already posted this but can't find it anywhere!

I'm having a problem that seems very simple. I'm trying to update a db and
am getting stuck on the data binding of a textbox. I get a "Cannot bind to
property or column permitnumber on DataSource" OR if I use ("text", ds,
"permits.permitnumber") nothing happens except that a permit number that
already exists shows up in the textbox. Do I have something in the wrong
order? HEre is my code:

Dim dbConn As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Projects\Tests\ParkingPErmits.mdb")
Dim da As New OleDbDataAdapter("select * from permits", dbConn)
Dim cb As New OleDbCommandBuilder(da)
Dim ds As New DataSet

da.UpdateCommand = cb.GetUpdateCommand
da.DeleteCommand = cb.GetDeleteCommand
da.InsertCommand = cb.GetInsertCommand
da.Fill(ds, "permits")

txtPermits.DataBindings.Clear()
txtPermits.DataBindings.Add(New Binding("text", ds, "permitnumber"))

da.Update(ds, "permits")

Thanks!
 
W

William Ryan eMVP

Lori:

Read my answer to your first question first b/c it's there's another issue
as well.
Hi, I already posted this but can't find it anywhere!

I'm having a problem that seems very simple. I'm trying to update a db and
am getting stuck on the data binding of a textbox. I get a "Cannot bind to
property or column permitnumber on DataSource" OR if I use ("text", ds,
"permits.permitnumber") nothing happens except that a permit number that
already exists shows up in the textbox. Do I have something in the wrong
order? HEre is my code:

Dim dbConn As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Projects\Tests\ParkingPErmits.mdb")
Dim da As New OleDbDataAdapter("select * from permits", dbConn)
Dim cb As New OleDbCommandBuilder(da)
Dim ds As New DataSet

da.UpdateCommand = cb.GetUpdateCommand
da.DeleteCommand = cb.GetDeleteCommand
da.InsertCommand = cb.GetInsertCommand
da.Fill(ds, "permits")

txtPermits.DataBindings.Clear()
txtPermits.DataBindings.Add(New Binding("text", ds, "permitnumber"))

da.Update(ds, "permits")

Thanks!
 

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

Top