Problem regenerating updatecommand

M

Maurice Mertens

Hi,

i'm having a problem with generating an updatcommand.
My form consists of 2 datasets, dsFS1 and dsFS100. The fields of dsFS1
are on tabpage1, the fields of dsFS100 are on tabpage2. dsFS1 contains 1
table: tblClient, dsFS100 also contains 1 table: tblTarieven. I declared
a oledbdataadapter global, daAdapter.

When a user opens the form, tabpage1 is displayed and after setting the
SELECT command for tblClient (SELECT * FROM tblClient) dsFS1 is filled
and the commandbuilder is used to generate the updatecommand for
tblClienten. So far everything goes well.

When tabpage2 is selected, the SELECT command of daAdapter is changed to
tblTarieven (SELECT * FROM tblTarieven) is set and dsFS100 is filled. I
used the commandbuilder to generate the UPDATE command for dsFS100. But
when I call daadapter.update(dsFS100, "tblTarieven") no changes are made
to the database. The row in the dataset has rowstate 'modified'. I
checked the updatecommand and was very supprised to see that it was the
updatecommand for tblClient (dsFS1).

I also tried RefreshSchema but this didn;t work. I can't change the
updatecommand by using the oledbcommandbuilder. Am I missing something?

strQry = "SELECT * " & _
"FROM tblTarieven " & _
"WHERE [TV-DebNr] = " & lngDebNr & ";"
daAdapter.SelectCommand.CommandText = strQry
cmb = New OleDb.OleDbCommandBuilder(daAdapter)
cmb.QuotePrefix = "["
cmb.QuoteSuffix = "]"
daAdapter.Fill(dsFS100, "tblTarieven")


the updatecommand doesn't change to tblTarieven but is still the
updatecommand for tblClient.


--
Met vriendelijke groet / With regards / Saludos,
Moviat Automatisering


Maurice Mertens
mauricem@moviat_KillSpamWordForEMail.nl

tel: +31 162 470 534
fax: +31 162 470 502
 
S

Sambathraj

Hi,
Best way to do this to have two different data adapters for each data set.
Regards,
Sambathraj
 
M

Maurice Mertens

Hi Sambathraj,

this would mean I have to declare a new dataadapter for each dataset I use
on my form. Is this what Microsoft has in mind? It looks to me it should be
possible to use just 1 dataadapter which handles all datasets.

I did some research and found out that a builder only generates the
updatecommand when the current updatecommand of the dataadapter is null. If
there's already an updatecommand (which is in my case) the current
updatecommand is used.
 
W

William \(Bill\) Vaughn

MS designed the DataAdapter to deal with a single table. That's one reason
(IMHO) that they are introducing the TableAdapter in V2.0.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 

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