Home All Groups Group Topic Archive Search About

Must be a better way to update or add using variable data

Author
12 Jan 2006 8:39 PM
Jim
Using VS 2005. I have bound fields on a form bound to a dataset(s) and I want
to add various data elements to fields in the DB that are not comming from
bound fields. This is what I have resorted to and it's not very efficient.
Any suggestions would be greatly appreciated

daPtName.InsertCommand.Parameters.Item("@Fname").Value = txtFname.Text
        daPtName.InsertCommand.Parameters.Item("@Mname").Value = txtMname.Text
        daPtName.InsertCommand.Parameters.Item("@Lname").Value = txtLname.Text
        daPtName.InsertCommand.Parameters.Item("@PFullName").Value =
txtFullName.Text
        daPtName.InsertCommand.Parameters.Item("@LFMName").Value = LFMName
        daPtName.InsertCommand.Parameters.Item("@SurgeonNo").Value = SurgeonNo
        daPtName.InsertCommand.Parameters.Item("@Title").Value = cboTitle.Text
        daPtName.InsertCommand.ExecuteNonQuery()

Also if I could make this a universal function that accepts any
dataadapter/dataset and allows me to access the un bound data for update or
addition would be great.
--
Thanks, Jim

Author
13 Jan 2006 7:56 AM
Cor Ligthert [MVP]
Jim,

I have to few information to give a complete answer. However a dataset has
this format

dataset.tables(TableNumberCollection).Rows(RowNumberCollection).Items(xxCollection)

This is not strongly typed. Strongly Typed you will see it by instance as
(where it is different in the STD versions 1.x and 2.0)

dataset.MyTable.Rows(Rownumber)(Columname)

That are the places to update.

I hope that this gives an idea

Cor