MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Insert query parameters not working

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ODBC Dotnet
Author Message
Roland



Joined: 08 Aug 2007
Posts: 1

PostPosted: Thu Oct 26, 2006 7:05 am    Post subject: Insert query parameters not working Reply with quote

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;-)?

Archived from group: microsoft>public>dotnet>framework>odbcnet
Back to top
View user's profile Send private message
Paul Clement



Joined: 08 Aug 2007
Posts: 154

PostPosted: Fri Oct 27, 2006 11:45 am    Post subject: Re: Insert query parameters not working Reply with quote

On Thu, 26 Oct 2006 03:05:02 -0700, Roland wrote:

¤ 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;-)?

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)

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Discovering parameters to Access queries? How can you discover parameters to queries, specifically Access queries, with ODBC.NET? For example, "Sales by Year" in I've read that such queries look more like stored procedures, but and return noth

Error 07002 SQLBindParameter not used for all parameters Hi, I created a simple VB.NET 2003 application through Visual Studio that connects to a MySQL database and loads a table into a Dataset, and then displays that table information in a DataGrid on a form for editing. The table fill works fine, the delete f

Trying to Insert a Record I'm trying to insert a new record into an MS Access table. The code below compiles and runs, but it doesn't write a record into the table. Can someone tell me why? Dim As New * FROM Sessions",

"Connection is dead" on ODBC insert of decimal into DB2 I am having problems inserting Decimal values into a DB2 database via a .NET/C# application which is using an Other field types such as VarChar, Int, Date, etc work ok, and I can insert literal values into a decimal field, but any attempt

System.Data.ODBC Blob insert problem Hi all, I am trying to use to insert a file into a binary field in SQL Server 2000. Now, before you yell at me, the reason I am doing this is that I am only writing intitial code against SQL, but this app will need to be able to run aga
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ODBC Dotnet All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group