Results 1 to 8 of 8

Thread: How to cast datakey in a DataBinding

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2013
    Posts
    134

    Re: How to cast datakey in a DataBinding

    @dunfiddlin
    I think that extremely unlikely. Databases generally make no distinction between numeric types. A number is a number is a number.
    I'm not sure I understood your point, but the fact is, that in the table in which a column contains a reference key to the other tables ID, the reference key column is defined as DOUBLE. Access says "If joining this field to a AutoNumber field in a many-to-one relationship, this field must be Long Integer". Nevertheless, the join with the Double field works in Access.

    BUT, probably the error I received was not due to this worng datatype in the column. Only after I have set up the cast( by adding the corresponding column to the DataTable and setting its DataType to Integer, before filling the table throught the OleDBAdapter):
    Code:
    Dim skPakas As New DataTable()
                skPakas.Columns.Add(New DataColumn("heap_id"))
                skPakas.Columns("heap_id").DataType = GetType(Integer)
                da.Fill(skPakas)
                myGrid2BindingSource.DataSource = skPakas
    which works fine and the data is filled while type Integer is preserved, I kept getting the error. Then I found out, that my alternative choices combobox, does not contain all possible values from the referencing table, and the error probably came from this and not from the misdatatyped reference key column. So I solved one problem, which probably didn't even cause the error.

    @jmcilhinney
    Would this additional column be bound in both directions (read/write) to the original column? Thanks anyway, but most probably the problem I wanted to solve was never a problem.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Apr 2013
    Posts
    134

    Re: How to cast datakey in a DataBinding

    I have to correct my statement from before.
    The manual cast of the Double-typed-key in the DataGridView's DataSource DataTable column MUST BE DONE, I just wanted to remove it, as I thought the problem's source was a different one, and there I got it again, so definitely one cannot use a BindingSource on a DataGridViewComboBoxColumn datatable's id(datatype Integer) and a DataGridViews DataTables column with datatype Double in the access database.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width