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 2077
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: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |