Re: InsertParameters.Add doesn't work in ASP.NET
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Thu, 26 Oct 2006 09:28:24 -0400
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.
.
- Prev by Date: Re: MDAC 2.8 - Command returning a Recordset in C++
- Next by Date: Reinstall Jet
- Previous by thread: Re: MDAC 2.8 - Command returning a Recordset in C++
- Next by thread: Re: InsertParameters.Add doesn't work in ASP.NET
- Index(es):
Relevant Pages
|
|