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

G

Guest

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.
 
C

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
 

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