473,472 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cannot insert the value NULL into column 'employeeid', table 'training.dbo.employee';

1 New Member
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using System.Data.SqlClient;
  9. using System.Configuration;
  10.  
  11.  
  12.  
  13. public partial class add : System.Web.UI.Page
  14. {
  15.     protected void Page_Load(object sender, EventArgs e)
  16.     {
  17.  
  18.     }
  19.     protected void btnadd_Click(object sender, EventArgs e)
  20.     {
  21.         int result = 0;
  22.         SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["sqlcon"]);
  23.         SqlCommand cmd = new SqlCommand("insertemployee", con);
  24.         cmd.CommandType = CommandType.StoredProcedure;
  25.         cmd.Parameters.Add("@employeename", SqlDbType.NVarChar, 50).Value = ename.Text.Trim();
  26.         cmd.Parameters.Add("@employeecourse", SqlDbType.NVarChar, 50).Value = ecourse.Text.Trim();
  27.         con.Open();
  28.         result = cmd.ExecuteNonQuery();
  29.             con.Close();
  30.             if (result > 0)
  31.                 Response.Write("employees are added");
  32.             else
  33.                 Response.Write("insertion in problems");
  34.  
  35.  
  36.     }
  37. }
  38.  
  39.  
  40. MY STOREPROCEDURES IS THIS
  41. USE [training]
  42. GO
  43. /****** Object:  StoredProcedure [dbo].[insertemployee]    Script Date: 11/28/2012 16:40:07 ******/
  44. SET ANSI_NULLS ON
  45. GO
  46. SET QUOTED_IDENTIFIER ON
  47. GO
  48.  
  49. ALTER PROCEDURE [dbo].[insertemployee](@employeename nvarchar(50),@employeecourse nvarchar(50))
  50. AS
  51. BEGIN
  52. INSERT INTO [employee]([employeename],[employeecourse])
  53.  
  54. VALUES
  55. (@employeename,@employeecourse)
  56.  
  57.  
  58. END
Nov 28 '12 #1
1 2111
Rabbit
12,516 Recognized Expert Moderator MVP
That is a very straight forward error. The employeeid field in the table training.dbo.employee can not be null.
Nov 28 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Chris Gilbert | last post by:
I'm quite stuck with this: I have an import table called ReferenceMatchingImport which contains data that has been sucked from a data submission. The contents of this table have to be imported...
3
by: Fabio Negri Cicotti [MCP] | last post by:
Hi All. I'm trying to insert data into 2 tables (parent-child) using the ADO.NET's SetParentRow method. The parent table has an identity column as primary key. When I execute the code below I...
6
by: Christopher Lusardi | last post by:
How can I fix this? When I do the below I get the error message: "Cannot insert explict value for identity column in table 'Employees' when IDENTITY_INSERT is set to OFF." To get this message,...
2
by: mivey4 | last post by:
Okay I have 2 tables: Table A - holds a list of new hardware serial numbers and their corresponding model (no constraints or indexes) Table B - holds a distinct list of current serial numbers...
0
by: diane | last post by:
Just trying to upsize using VFP 9 with SQL 2005 using VFP remote views. One in particular keeps coming up and saying Cannot insert the value NULL into column, when I really don't think I am...
1
by: billa856 | last post by:
Hi, I am trying to insert Null value in column(ShipDate) in my table.That column(ShipDate)'s type id date/time and format is short date. I am using "" to insert Null in that column(ShipDate)...
6
by: pbd22 | last post by:
Hi. I am trying to insert a zero into the below table and I am being told that: Cannot insert the value NULL into column 'UsageToday', table DB.dbo.Pub_Count'; column does not allow nulls....
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
3
by: Jake77 | last post by:
Hey I'm trying to nsert a raw to a table that has one column marked with identity ON. The code is like this: string sqlString1 = "INSERT into T_Branches (BranchTypeID,...
1
by: Octo Siburian | last post by:
I have been collecting data from ms.access database into a class object '_Get and put in data from database Fingerprint(RAS) into CPresensiFingerprint Public Function GetdbFingerprint() As...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.