Re: InsertParameters.Add doesn't work in ASP.NET



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

There was no way for you to know it (except maybe by browsing through
some of the previous questions in this newsgroup before posting yours -
always a recommended practice) , but this is a classic ADO newsgroup.
ADO.Net bears very little resemblance to classic ADO so, while you may
be lucky enough to find a dotnet-knowledgeable person here who can
answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-knowledgeable people hang out. I
suggest microsoft.public.dotnet.framework.adonet.

MyDataSource.InsertParameters.Clear();
MyDataSource.InsertParameters.Add("AdvID", TypeCode.String, sAdvID);
MyDataSource.InsertParameters.Add("Name", txtName.Text);
MyDataSource.InsertCommand = "INSERT INTO markt.advertizers " +
"(AdvID, Email, Name) VALUES (@AdvID,@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;-)?

It depends. There are several possible solutions, some of which might
not be suitable for your situation.

A. Configure AdvID to accept nulls
B. Provide a default value for sAdvID if it has no value
C. Don't allow the form to be submitted if sAdvID has no value
D. Assign "" (empty string) to sAdvID if it is Null

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


.



Relevant Pages

  • Mahjong FAQs
    ... FAQ 4b - Added link to new Chinese-language site about Japanese mahjong. ... Introduction to Mah-Jongg Newsgroup ... FAQ11b Origins: Precursor Games ... NEWSGROUP POSTING ARCHIVES: ...
    (rec.games.mahjong)
  • Mah-Jongg FAQs
    ... Introduction to Mah-Jongg Newsgroup ... FAQ11b Origins: Precursor Games ... American Mah-Jongg FAQs ... NEWSGROUP POSTING ARCHIVES: ...
    (rec.games.mahjong)
  • Mah Jong FAQs
    ... Introduction to Mah-Jongg Newsgroup ... FAQ11b Origins: Precursor Games ... American Mah-Jongg FAQs ... NEWSGROUP POSTING ARCHIVES: ...
    (rec.games.mahjong)
  • Mah-Jongg FAQs updated
    ... FAQ 4a - Added a teacher listing. ... Introduction to Mah-Jongg Newsgroup ... FAQ11b Origins: Precursor Games ... NEWSGROUP POSTING ARCHIVES: ...
    (rec.games.mahjong)
  • Re: Mah-Jongg FAQs updated
    ... FAQ 5 - Added a link to free mah-jongg tile graphics, ... Introduction to Mah-Jongg Newsgroup ... FAQ11b Origins: Precursor Games ... NEWSGROUP POSTING ARCHIVES: ...
    (rec.games.mahjong)