Solved

Update source data from Dataset ***Urgent*** !

Posted on 2004-10-09
8
190 Views
Last Modified: 2010-04-24
I already have a dataset filled by few data adapters.
I am trying to add a record to a certain table's column and update the source database from dataset.
The source database is done in access (in case it might help)

dataset: ds
dataadapter: daPrj
table in dataset: prj
columns in table: prjNo(key, autonumber), prjName(string), prjFinished(yes/no)

When i try to update by using the following commands, a messagebox pops up saying "Parameter ?_1 has no default value"
I also tried to update by using this command but it does not actually update the database:
    daPrj.Update(ds)

 Private Sub mnuFilePrjNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFilePrjNew.Click
        Dim myRow As DataRow = ds.prj.NewRow
        myRow(ds.prj.prjNameColumn) = "newly added project name"
        myRef.ds.prj.Rows.Add(myRow)
       
        Try
            daPrj.Update(ds, "prj")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
End Sub


0
Comment
Question by:UnFiRe
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 12268305
Hi UnFiRe:
Maybe you should also provide a value for prjFinished?

Dabas
0
 
LVL 1

Author Comment

by:UnFiRe
ID: 12268328
i have tried that - still the same error
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12268558
I think you must define the daPrj.UpdateCommand  property.
Look this article, maybe that help you,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconupdatingdatabasewithdataadapterdataset.asp

Good Luck
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Accepted Solution

by:
Dabas earned 350 total points
ID: 12269584
UnFiRe:
Would you mind posting the Insert Command of the DataAdpater?

Dabas
0
 
LVL 4

Assisted Solution

by:eozz_2000
eozz_2000 earned 150 total points
ID: 12270438
Please put the sql of all commands.
0
 
LVL 1

Author Comment

by:UnFiRe
ID: 12271608
There is few more columns now. Thanks to you guys i have found something that was out of order - i gave the name of daPrj to another DA instead (late night programming). After i have gave right names to the adapters the msgbox does not popup anymore, however, the database does not get updated. It still has the same records after it should have gotten updated. Here are all the commands:

****** Update ****
UPDATE    prj
SET              prjDone = ?, prjEdited = ?, prjName = ?, prjTaken = ?, qSessions = ?
WHERE     (prjNo = ?) AND (prjDone = ?) AND (prjEdited = ?) AND (prjName = ?) AND (prjTaken = ?) AND (qSessions = ?) OR
                      (prjNo = ?) AND (prjDone IS NULL) AND (prjEdited IS NULL) AND (prjName IS NULL) AND (prjTaken IS NULL) AND (qSessions IS NULL) AND
                      (? IS NULL) OR
                      (prjNo = ?) AND (prjDone = ?) AND (prjEdited = ?) AND (prjName = ?) AND (prjTaken = ?) AND (qSessions IS NULL) AND (? IS NULL) OR
                      (prjNo = ?) AND (prjDone = ?) AND (prjEdited = ?) AND (prjName IS NULL) AND (prjTaken IS NULL) AND (qSessions IS NULL) AND (? IS NULL) AND
                      (? IS NULL)

***** Insert *******
INSERT INTO prj
                      (prjDone, prjEdited, prjName, prjTaken, qSessions)
VALUES     (?, ?, ?, ?, ?)

***** Delete *****
DELETE FROM prj
WHERE     (prjNo = ?) AND (prjDone = ?) AND (prjEdited = ?) AND (prjName = ? OR
                      ? IS NULL AND prjName IS NULL) AND (prjTaken = ?) AND (qSessions = ? OR
                      ? IS NULL AND qSessions IS NULL)
0
 
LVL 1

Author Comment

by:UnFiRe
ID: 12271629
Ok, Never mind now folks - i forgot to uncomment the Add statement. You helped me with your great hints. Thanks a lot!
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12272646
Your Welcome.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question