Re: I can find it, why can't my code?

Tech-Archive recommends: Speed Up your PC by fixing your registry



You create an Array of datacolumns (even if it's just one column) and then
set it accordingly. that's the right syntax, but here's an example i wrote
a while back that walks you through it
http://www.knowdotnet.com/articles/adopartiii.html
"PaulNaude" <PaulNaude@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1E099864-883E-48C2-A678-0151BEFEA548@xxxxxxxxxxxxxxxx
> Thank again!
>
> I didn't realise that is important to set up the primary keys on the .NET
> side as well! in all the other cases everything worked as intended. I will
> try this and let you know.
>
> PS: The book I have from Rick Dobson as well as the online help is very
> sketchy about how to set the primary key for a dataset table which exist
> in a
> db.
> Is it correct to use:
> dataset.table(0).primarykey = new datacolumn()
> {dataset.table(0).columns(0)
> dataset.table(0).columns(1) dataset.table(0).columns(2)}
>
> Regards
>
> "W.G. Ryan - MVP" wrote:
>
>> Paul - I know you've probably already checked this, but it should be
>> working. Just to be safe, you are sure that the PrimaryKey is defined on
>> the DataTable object as well as in the database (although it being in the
>> db
>> is not necessary). I only ask b/c you mention that PrimaryKey in the
>> database, but you must use the PK of the datatable as well. If not, you
>> get
>> erratic behavior. The fact that deleting it via the grid works is a
>> different issue b/c it's not running the same code, so when you delete
>> the
>> row, it knows the index of the datatable and deletes is accordingly.
>> Double
>> check the PrimaryKey property of the table (http://shrinkster.com/8rf )
>> [the datatable locally) just to be sure. If that matches what you
>> expect,
>> then this behavior is weird indeed - we'll take it from there if that's
>> the
>> case
>> "PaulNaude" <PaulNaude@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:0B03FCD0-E3BD-4657-98DA-856867BA8716@xxxxxxxxxxxxxxxx
>> >I have a problem deleting a record from a table with 3 primary keys, in
>> >code.
>> > I get the values of the primary keys from my datagrid displaying the
>> > record
>> > to be deleted as follows:
>> > ...
>> > findTheseVals(0) = DataGrid4.Item(u, 0) 'First column and unique
>> > primary
>> > key
>> > (no duplicates allowed)
>> > findTheseVals(1) = DataGrid4.Item(u, 1) 'Second column and primary key
>> > (duplicates ok)
>> > findTheseVals(2) = DataGrid4.Item(u, 2) 'Third column and primary key
>> > (duplicates ok)
>> > ...
>> >
>> > Then, to delete the record from the table, I use
>> >
>> > DataSet11.Tables("Equipment").Rows.Find(findTheseVals).Delete()
>> >
>> > but get the following error:
>> >
>> > An unhandled exception of type 'System.NullReferenceException' occurred
>> > in
>> > App.exe
>> > Additional information: Object reference not set to an instance of an
>> > object.
>> >
>> > i.e. this record was not found, although I can physically see it in the
>> > table.
>> >
>> > I checked the populated values of findTheseVals and it matches my
>> > primary
>> > key values (and types) in the database table exactly.
>> > The column orders in the dataAdapter, datagrid and database table are
>> > identical.
>> > I checked that the table referenced is exactly the same as the one
>> > referenced by the datagrid etc.
>> >
>> > When I manually delete the row from my datagrid, the record is
>> > correctly
>> > deleted from the database.
>> >
>> > What am I missing here?
>>
>>
>>


.



Relevant Pages

  • Re: interview questions
    ... the most important thing is that they understand database DESIGN. ... There is no such thing as multiple primary keys in a ... Should an Autonumber field be used as a Primary Key? ... Normalization is a methodology or process for removing as much redundant ...
    (microsoft.public.access.tablesdbdesign)
  • Re: interview questions
    ... the most important thing is that they understand database DESIGN. ... There is no such thing as multiple primary keys in a ... Should an Autonumber field be used as a Primary Key? ... Normalization is a methodology or process for removing as much redundant ...
    (microsoft.public.access.tablesdbdesign)
  • RE: Dataset.merge method
    ... and Deleted are matched on primary keys. ... > from my database with another one that is filled with values from my active ... > My messed up display name ... > AGoodLastName ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Updating the SQL key value
    ... Auto-numbered synthetic primary keys are the root of all evil. ... usually indicate a lazy approach to database design. ... What if your database must be upgraded and the logic changes? ... I don't get it why you think of that as 'the root of all evil'. ...
    (comp.lang.php)
  • RE: Another design advice
    ... Could you post the reason of such recommendation? ... > One of the main concerns I have is with respect to primary keys. ... > types of transactions such as expenses, payments, deposits, etc... ... > this on the database. ...
    (microsoft.public.sqlserver.programming)