Second binding

  • Thread starter Thread starter Brad Allison
  • Start date Start date
B

Brad Allison

If I need to post code, I will do so, but I think explaining my question my
result in a good answer.

I have a form that asks a user for a unique id number. This then runs the
data adapter's parametized query and then fills a dataset with the one
resulting row. This works fine and dandy.

On this same form I have a RESET button (in case the user determins that the
wrong information has been entered). This clears the form and the dataset
and present the user with the blank text box in which they need to enter
another unique number.

Here is the problem: when I try to run this, something seems to be going on
with the databindings on the form's controls because the second time,
nothing is being bound. One of the fields that is being passed is a date
and this is where the program errors. It is tring to pass "" as a date.

Any information or insite would be greatly appreciated.

Thanks,

Brad
 
Brad,

I suspect you are creating a new instance of the datatable and you are
either still bound to the previous table or you are binding to the new table
and filling the old table.

-Sam Matzen
 
Mr Ryan,

It is coming up after the second fill. I am grabbing this information from
an AS400 through ODBC. The date comes down in decimal format so I have a
short subroutine to convert the decimal value.ToString then insert a leading
0 if needed and insert the "/". The code for that works fine. It is just
the second dataadapter.fill(ds) does not seem to be binding the data.

Thanks for the help and if you do need the code (some of it is extensive) I
can post it.

Brad
 
Brad:

Where is this error popping up, before or after you do the second fill.
What I'm getting at is is the second fill working and the bindings are going
bust? If you could show the code it would be helpful.

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
That is what I was thinking too, but in the Reset Button procedure, I have a
ds.clear() statement. I also through in a bindingcontext.count line to see
how many records the table contained.
 
Mr Ryan,

I think I found the culprit, but I still don't know why.

I have this:
AddHandler lblDOB.DataBindings("Text").Format, AddressOf lbldob_Format

Private Sub lbldob_Format(ByVal sender As Object, ByVal e As ConvertEventArgs)

e.Value = CType(e.Value, DateTime).ToString("MMMM dd, yyyy")

End Sub

When I remarked this section out, it works fine.

Brad
 
I noticed in your other reply you are checking the rows.count so that's
verified right? If you get an error then the bind isn't going to work. Can
you use the exact same value and rebind to it, or is it failing with the
same data. I'm just wondering if the date is the issue but b/c the values
are different for different records it shows itself on the second query.

Another approach might be to pull over all of the data (or a subest of it)
and use a DataRelation (if tables are related) and just use the binding to
automatically show the filtered records. If possible, it might be a good
idea to minimize the trips to the DB and you might kill two birds with one
stone.

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
if the as400 date is mmddyy then you could use the format object to convert it to an integer and then a date. I use this routine in my as400 programming.
e.value = CType(CType(e.value,Integer).ToString("00/00/00"), DateTime)


Mr Ryan,

I think I found the culprit, but I still don't know why.

I have this:
AddHandler lblDOB.DataBindings("Text").Format, AddressOf lbldob_Format

Private Sub lbldob_Format(ByVal sender As Object, ByVal e As ConvertEventArgs)

e.Value = CType(e.Value, DateTime).ToString("MMMM dd, yyyy")

End Sub

When I remarked this section out, it works fine.

Brad
 
Gary,

It does not come down that way. If the date is July 4, 2004 it will come down as 7042004. Conversely if the date is October 1, 2004 it will come down as 10012004. The dd seems to always have a leading 0, but the month does not. I wrote a short subroutine to convert the decimal to string, see the string length, insert the leading 0 if necessary then insert the "/".

Thanks for the information.

Brad
if the as400 date is mmddyy then you could use the format object to convert it to an integer and then a date. I use this routine in my as400 programming.
e.value = CType(CType(e.value,Integer).ToString("00/00/00"), DateTime)


Mr Ryan,

I think I found the culprit, but I still don't know why.

I have this:
AddHandler lblDOB.DataBindings("Text").Format, AddressOf lbldob_Format

Private Sub lbldob_Format(ByVal sender As Object, ByVal e As ConvertEventArgs)

e.Value = CType(e.Value, DateTime).ToString("MMMM dd, yyyy")

End Sub

When I remarked this section out, it works fine.

Brad
 
Back
Top