Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread EDBParameters not implemented in ADO.NET?
Sat, Feb 14 2009 6:13 AMPermanent Link

"Hedley Muscroft"
This code works fine :-

     EDBCommand cmd = new EDBCommand("insert into occupation (id, name)
values (100, 'Blobby')", con);
     cmd.ExecuteNonQuery();

But the following :-

     EDBCommand cmd = new EDBCommand("insert into occupation (id, name)
values (Tongue, Tongue)", con);
     cmd.Parameters.Add(new EDBParameter("p1", 100));
     cmd.Parameters.Add(new EDBParameter("p2", "Blobby"));
     cmd.ExecuteNonQuery();

....throws a "ElevateDB Error #1004 The column id in the table occupation
cannot be NULL".

"id" is NOT NULL integer field, "name" is a varchar(100) field.

Is this a bug EDB ADO.NET or am I doing something wrong?

Thanks.
Sat, Feb 14 2009 7:54 PMPermanent Link

Robin Joseph
Hedley

I generally use stored procedures and the parameters are automatically created when you
cmd.Prepare();
then
cmd.Parameters[0].value = 100;
cmd.Parameters[1].value = 'Blobby';
cmd.ExecuteNonQuery();

ie - you don't need cmd.Parameters.Add....

Also - In a stored procedure you would use values(?,?) not values(Tongue, Tongue)

Hope this helps

Robin Joseph

"Hedley Muscroft" wrote:

This code works fine :-

     EDBCommand cmd = new EDBCommand("insert into occupation (id, name)
values (100, 'Blobby')", con);
     cmd.ExecuteNonQuery();

But the following :-

     EDBCommand cmd = new EDBCommand("insert into occupation (id, name)
values (Tongue, Tongue)", con);
     cmd.Parameters.Add(new EDBParameter("p1", 100));
     cmd.Parameters.Add(new EDBParameter("p2", "Blobby"));
     cmd.ExecuteNonQuery();

....throws a "ElevateDB Error #1004 The column id in the table occupation
cannot be NULL".

"id" is NOT NULL integer field, "name" is a varchar(100) field.

Is this a bug EDB ADO.NET or am I doing something wrong?

Thanks.
Sat, Feb 14 2009 9:38 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Hedley,

<< But the following :-

     EDBCommand cmd = new EDBCommand("insert into occupation (id, name)
values (Tongue, Tongue)", con);
     cmd.Parameters.Add(new EDBParameter("p1", 100));
     cmd.Parameters.Add(new EDBParameter("p2", "Blobby"));
     cmd.ExecuteNonQuery();

...throws a "ElevateDB Error #1004 The column id in the table occupation
cannot be NULL". >>

You need to use this code:

     EDBCommand cmd = new EDBCommand("insert into occupation (id, name)
values (Tongue, Tongue)", con);
     cmd.Parameters.Clear(); <<<<<<<<<<<<<<<<
     cmd.Parameters.Add(new EDBParameter("p1", 100));
     cmd.Parameters.Add(new EDBParameter("p2", "Blobby"));
     cmd.ExecuteNonQuery();

You can manually add the parameters, but you need to make sure to set the
EDBCommand.ParamCheck property to False or Clear any existing parameters
automatically created by ElevateDB.  Otherwise, you're adding 2 parameters
*on top* of the 2 parameters already set up for you by ElevateDB.  Usually
we just recommend that you use code like this:

     EDBCommand cmd = new EDBCommand("insert into occupation (id, name)
values (Tongue, Tongue)", con);
   cmd.Parameters["p1"].Value = 100;
   cmd.Parameters["p2"].Value = "Blobby";
   cmd.ExecuteNonQuery();

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Feb 17 2009 5:06 AMPermanent Link

"James Relyea"
If you are using .Net 2.0 or later, you might want to look at TableAdapters.
If you use them + ElevateDB Stored Procedures, the parameters are
automatically created (and properly). You'll have to set the column binding.
If you're using 2.02, remove the double quotes from the stored proc name in
the tableadapter and the datatable will also be generated.

It'll save you a ton of coding time in the long run.

Smile
jr


"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:29E61C55-604C-43D0-B221-EEBF6BC3B15A@news.elevatesoft.com...
> Hedley,
>
> << But the following :-
>
>      EDBCommand cmd = new EDBCommand("insert into occupation (id, name)
> values (Tongue, Tongue)", con);
>      cmd.Parameters.Add(new EDBParameter("p1", 100));
>      cmd.Parameters.Add(new EDBParameter("p2", "Blobby"));
>      cmd.ExecuteNonQuery();
>
> ...throws a "ElevateDB Error #1004 The column id in the table occupation
> cannot be NULL". >>
>
> You need to use this code:
>
>      EDBCommand cmd = new EDBCommand("insert into occupation (id, name)
> values (Tongue, Tongue)", con);
>      cmd.Parameters.Clear(); <<<<<<<<<<<<<<<<
>      cmd.Parameters.Add(new EDBParameter("p1", 100));
>      cmd.Parameters.Add(new EDBParameter("p2", "Blobby"));
>      cmd.ExecuteNonQuery();
>
> You can manually add the parameters, but you need to make sure to set the
> EDBCommand.ParamCheck property to False or Clear any existing parameters
> automatically created by ElevateDB.  Otherwise, you're adding 2 parameters
> *on top* of the 2 parameters already set up for you by ElevateDB.  Usually
> we just recommend that you use code like this:
>
>      EDBCommand cmd = new EDBCommand("insert into occupation (id, name)
> values (Tongue, Tongue)", con);
>    cmd.Parameters["p1"].Value = 100;
>    cmd.Parameters["p2"].Value = "Blobby";
>    cmd.ExecuteNonQuery();
>
> --
> Tim Young
> Elevate Software
> www.elevatesoft.com
>

Image