Hi friends i have a probelm i am try to pass the value to the employeeid parameter but getting th error please help me how i can do this i am getting the error here is my code -
using System;
-
using System.Collections;
-
using System.ComponentModel;
-
using System.Data;
-
using System.Drawing;
-
using System.Web;
-
using System.Web.SessionState;
-
using System.Web.UI;
-
using System.Web.UI.WebControls;
-
using System.Web.UI.HtmlControls;
-
using System.Data.SqlClient;
-
using System.Data.SqlTypes;
-
using System.DirectoryServices;
-
-
namespace Accomplishments
-
{
-
/// <summary>
-
/// Summary description for Accomplishment.
-
/// </summary>
-
public class Accomplishment : System.Web.UI.Page
-
{
-
protected System.Web.UI.WebControls.TextBox txtFirstName;
-
protected System.Web.UI.WebControls.TextBox txtLastName;
-
protected System.Web.UI.WebControls.TextBox txtdatecreated;
-
protected System.Web.UI.WebControls.TextBox txtProject;
-
protected System.Web.UI.WebControls.TextBox txtdescription;
-
protected System.Web.UI.WebControls.TextBox Login;
-
protected System.Web.UI.WebControls.TextBox txtLogin;
-
protected System.Web.UI.WebControls.DropDownList drpProject;
-
protected System.Web.UI.WebControls.TextBox txtdept;
-
protected System.Web.UI.WebControls.RequiredFieldValidator Project;
-
protected System.Web.UI.WebControls.DropDownList drpMonth;
-
protected System.Web.UI.WebControls.Button cmdSubmit;
-
-
private void Page_Load(object sender, System.EventArgs e)
-
{
-
txtdatecreated.Text = DateTime.Now.ToShortDateString();
-
// Put user code to initialize the page here
-
if(Session["Login"].ToString() != null)
-
{
-
this.txtLogin.Text=Session["Login"].ToString();
-
}
-
-
if(Session["fn"].ToString() != null)
-
{
-
this.txtFirstName.Text=Session["fn"].ToString();
-
}
-
-
if(Session["sn"].ToString() != null)
-
{
-
this.txtLastName.Text=Session["sn"].ToString();
-
}
-
-
if(Session["department"].ToString() != null)
-
{
-
this.txtdept.Text=Session["department"].ToString();
-
}
-
-
}
-
-
#region Web Form Designer generated code
-
override protected void OnInit(EventArgs e)
-
{
-
//
-
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
-
//
-
InitializeComponent();
-
base.OnInit(e);
-
}
-
-
/// <summary>
-
/// Required method for Designer support - do not modify
-
/// the contents of this method with the code editor.
-
/// </summary>
-
private void InitializeComponent()
-
{
-
this.cmdSubmit.Click += new System.EventHandler(this.cmdSubmit_Click);
-
this.Load += new System.EventHandler(this.Page_Load);
-
-
}
-
#endregion
-
-
-
-
private void cmdSubmit_Click(object sender, System.EventArgs e)
-
{
-
SqlConnection oConn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]);
-
SqlDataAdapter da=new SqlDataAdapter("dbo.writeAccomplishment", oConn);
-
da.SelectCommand.CommandType=CommandType.StoredProcedure;
-
-
da.SelectCommand.Parameters.Add(new SqlParameter("@FirstName",txtFirstName.Text));
-
da.SelectCommand.Parameters.Add(new SqlParameter("@LastName",txtLastName.Text));
-
da.SelectCommand.Parameters.Add(new SqlParameter("@AccompDesc",txtdescription.Text));
-
da.SelectCommand.Parameters.Add(new SqlParameter("@datecreated",txtdatecreated.Text));
-
da.SelectCommand.Parameters.Add(new SqlParameter("@deptname",txtdept.Text));
-
da.SelectCommand.Parameters.Add(new SqlParameter("@ProjectId",drpProject.SelectedItem.Value));
-
-
// SqlParameter ReturnID = new SqlParameter("@EmployeeID", SqlDbType.Int);
-
// ReturnID.Direction = ParameterDirection.Output;
-
// da.SelectCommand.Parameters.Add(ReturnID);
-
oConn.Open();
-
da.SelectCommand.ExecuteNonQuery();
-
oConn.Close();
-
-
-
}
-
}
-
-
-
}
-
-
-
-
and here is the store procedure -
CREATE procedure dbo.writeAccomplishment
-
-
-
(
-
@firstname varchar(50),
-
@lastname varchar(50),
-
@AccompDesc varchar(2000),
-
@DeptName varchar(50),
-
@Projectid int,
-
@datecreated datetime,
-
@Employeeid int
-
-
)
-
as
-
-
--declare @employeeid int
-
select EmployeeID from Employee
-
where employeeid=@Employeeid
-
-
IF EXISTS(SELECT employeeid FROM Employee WHERE Firstname = @FirstName and LastName=@LastName)
-
-
BEGIN
-
SELECT 'This record already exists!'
-
-
--insert into Employee
-
-
--(EmployeeId)--,FirstName, LastName,DeptName)
-
-
-
--Values (@@Identity)--,@FirstName,@LastName,@DeptName)
-
-
-
Insert into Accomplishment (Employeeid,AccompDesc,ProjectId,Datecreated)
-
-
values (@employeeid,@AccompDesc,@ProjectId,@datecreated)
-
-
END
-
else
-
BEGIN
-
--SELECT 'Add this EmployeeID'
-
-
insert into Employee
-
-
(DeptName,FirstName,LastName)
-
-
Values (@DeptName,@FirstName,@LastName)
-
-
-
Insert into Accomplishment (Employeeid,AccompDesc,Projectid,datecreated)
-
-
values (@employeeid,@AccompDesc,@projectid,@datecreated)
-
-
--set @employeeID = @employeeid
-
-
--return @employeeID
-
END
-
GO
-
-
-
4 2072
The parameters that you pass must match the parameter names in your stored procedure
da.SelectCommand.Parameters.Add(new SqlParameter("@FirstName",txtFirstName.Text));
da.SelectCommand.Parameters.Add(new SqlParameter("@LastName",txtLastName.Text));
da.SelectCommand.Parameters.Add(new SqlParameter("@AccompDesc",txtdescription.Text));
da.SelectCommand.Parameters.Add(new SqlParameter("@datecreated",txtdatecreated.Text));
da.SelectCommand.Parameters.Add(new SqlParameter("@deptname",txtdept.Text));
da.SelectCommand.Parameters.Add(new SqlParameter("@ProjectId",drpProject.SelectedItem.Value));
Change the parameters you are passing to match identically to the parameters defined in the stored procedure.
Nathan
hey i have a employeeid too but i don't have a text box for that employeeid i need to pass the value to employeeid not know how i can do that please help me
hey i have a employeeid too but i don't have a text box for that employeeid i need to pass the value to employeeid not know how i can do that please help me
Based on your proc it looked like you were trying to make the employeeid an @@Identity column. If this is the case employeeid would autoincrement each time a new employee was inserted into your table. There is no need to pass a parameter to do this. Your stored proc will do it for you. If you are unsure about what your stored proc is doing post your proc in the SQL forum and they can help you get the stored proc written correctly.
Nathan
i am getting this error don't what to do
Cannot insert the value NULL into column 'EmployeeID', table 'Accomplishments.dbo.Accomplishment'; column does not allow nulls. INSERT fails. The statement has been terminated.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: sara |
last post by:
Hi
I'm pretty new to Access here (using Access 2000), and appreciate the
help and instruction.
I gave myself 2.5 hours to research online and help and try to get this
one, and I am not getting...
|
by: dbuchanan |
last post by:
Hello,
Here is the error message;
----------------------------
Exception Message:
ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child
key values (5) to exist in the...
|
by: ruju00 |
last post by:
I am getting an error in Login() method of the following class
FtpConnection
public class FtpConnection
{
public class FtpException : Exception
{
public FtpException(string message) :...
|
by: knowthediff |
last post by:
Hello,
I have a VS2003 app that I moved to VS 2005. I am trying to correct
the error that I now receive when the app runs. In several places I am
getting a InvalidOperationException...
|
by: bagya |
last post by:
please help me out
the following is the small code i have
<html>
<head>
<script type="text/javascript">
function validate()
{
if (document.abc.region.value==0)
|
by: preeti13 |
last post by:
Hi guys i am here with my another probelm please help me.trying insert the value into the data base but getting the null value error .I am getting thsi error
Cannot insert the value NULL into...
|
by: buntyindia |
last post by:
Hi,
I have a very strange problem with my application.
I have developed it using Struts.
I have a TextBox With Some fixed value in it and on Submit iam passing it to another page.
<html:form...
|
by: vikas251074 |
last post by:
I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support...
|
by: raghuvendra |
last post by:
Hi
I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button.
All these are aligned in a row. And Each Category Name has its corresponding Category...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |