[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Insert query parameters not working

Roland

10/26/2006 10:05:00 AM

In my application (ASP.net) I use the following:

MyDataSource.InsertParameters.Clear();
MyDataSource.InsertParameters.Add("AdvID", TypeCode.String, sAdvID);
MyDataSource.InsertParameters.Add("Email", txtEmail.Text);
MyDataSource.InsertParameters.Add("Name", txtName.Text);
MyDataSource.InsertCommand = "INSERT INTO markt.advertizers " +
"(AdvID, Email, Name) VALUES (@AdvertiserID,@Email,@Name)";
MyDataSource.Insert();

When I run the app, I get the excheption:
"ERROR [HYT00] [MySQL][ODBC 3.51 Driver][mysqld-5.0.24a-community-nt]Column
'AdvID' cannot be null"

What do I do wrong here (except for using MySQL;-)?
2 Answers

Paul Clement

10/27/2006 12:46:00 PM

0

On Thu, 26 Oct 2006 03:05:02 -0700, Roland <Roland@discussions.microsoft.com> wrote:

&#164; In my application (ASP.net) I use the following:
&#164;
&#164; MyDataSource.InsertParameters.Clear();
&#164; MyDataSource.InsertParameters.Add("AdvID", TypeCode.String, sAdvID);
&#164; MyDataSource.InsertParameters.Add("Email", txtEmail.Text);
&#164; MyDataSource.InsertParameters.Add("Name", txtName.Text);
&#164; MyDataSource.InsertCommand = "INSERT INTO markt.advertizers " +
&#164; "(AdvID, Email, Name) VALUES (@AdvertiserID,@Email,@Name)";
&#164; MyDataSource.Insert();
&#164;
&#164; When I run the app, I get the excheption:
&#164; "ERROR [HYT00] [MySQL][ODBC 3.51 Driver][mysqld-5.0.24a-community-nt]Column
&#164; ''AdvID'' cannot be null"
&#164;
&#164; What do I do wrong here (except for using MySQL;-)?

It looks like your parameter is misnamed. The parameter name in your query is @AdvertiserID while
the name of the parameter you are adding to the Parameter collection is AdvID.


Paul
~~~~
Microsoft MVP (Visual Basic)

J. Weaver Jr.

6/9/2010 1:46:00 PM

0

ldnayman wrote:
> It is sad. Someone here coined the phrase once "You've got questions -
> we've got blank stares!"
>
> But again, what do you expect. Radio Shack is generally staffed by 17
> year old kids making $8 an hour, so do you really expect them to know
> what a diode is?

Back when _I_ was one of those 17 year old kids, making considerably
less than $8 an hour, I worked at The Shack _because_ I knew what a
diode (and most everything else in the store) was. And so did everyone
else who worked with me.

<shrug> -JW