DataSet Update Problem

mmb

Active member
Joined
Aug 1, 2004
Messages
42
Programming Experience
1-3
Hi
I made a FORM by Simply Binding and Complex binding the Controls.

I have buttons on the FORM ADD,DELETE And CANCEL which directly affects the DATASET.

On save button I have used the dataset method UPDATE that is


DataAdapter.update(dataset,"TableName")

But I get exception that Proper Query Required.

Pls help me out.
 

DavidT_macktool

Well-known member
Joined
Oct 21, 2004
Messages
502
Location
Indiana
Programming Experience
3-5
Have you tried using the dataform wizard to generate the Update code. You could start a new form and copy the code or just use the dataform and update it. The wizard also handles add, delete, and cancel code. You should be able to easily replicate your form and have the code written for you.
 

mmb

Active member
Joined
Aug 1, 2004
Messages
42
Programming Experience
1-3
I want to do it through CODE

Thanks for the Help buddy.

I know that dataform wizard can generate me a form that I want. But I want to do it through code. If any can help me throught code I'll really be thankful.

Regards.
 

mzim

Well-known member
Joined
Jun 3, 2004
Messages
187
Location
Other side of the rock
Programming Experience
1-3
mmb said:
Hi
I made a FORM by Simply Binding and Complex binding the Controls.

I have buttons on the FORM ADD,DELETE And CANCEL which directly affects the DATASET.

On save button I have used the dataset method UPDATE that is


DataAdapter.update(dataset,"TableName")

But I get exception that Proper Query Required.

Pls help me out.
what do ya mean by proper query required?
 

DavidT_macktool

Well-known member
Joined
Oct 21, 2004
Messages
502
Location
Indiana
Programming Experience
3-5
can you provide code?

What does your update command look like, can you provide code?

SqlUpdateCommand1.CommandText = "UPDATE [Table Name] SET Variable1 = @Param1, Variable2 = @Param2, Variable3 = @Param3
WHERE (Variable1 = @Original_Variable1) AND (Variable2 = @Original_Variable2) AND (Variable3 = @Original_Variable3 OR @Original_Variable3 IS NULL AND Variable3 IS NULL)
; SELECT Variable1, Variable2, Variable3 WHERE (Variable1 = @Param1) AND (Variable2 = @Param2)"

This is the wizard generated update command, variables 1 and 2 are key fields and variable3 allows nulls. Does this help?
sounds like you have a problem with this command but the help guys here would need to see it to be sure.
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
The DataForm Wizard can help you 'through code'.

The Wizard will ask you a set of questions and when you press finish, it will generate the Form and DataSet Schema with all the code needed to operate the form based on your answers. Then you can have a look at the code and see how it's done and even modify it to suit you needs.
 
Top Bottom