HI,
protected void btnUpdate_Click(object sender, EventArgs e)
{
SqlConnection MyConnection;
SqlCommand MyCommand;
MyConnection = new SqlConnection();
MyConnection.ConnectionString =
ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
MyConnection.Open();
MyCommand = new SqlCommand("StaffApplyLeave", MyConnection);
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.Add("@h_id", Request.QueryString["h_id"]);
MyCommand.Parameters.Add("@sh_id", Request.QueryString["staff_id"]);
MyCommand.Parameters.Add("@h_name", txtName.Text);
MyCommand.Parameters.Add("@h_from", txtFrom.Text);
MyCommand.Parameters.Add("@h_till", txtTill.Text);
MyCommand.Parameters.Add("@h_add", txtA1.Text + txtA2.Text);
MyCommand.Parameters.Add("@h_post", txtPost.Text);
MyCommand.Parameters.Add("@h_dept", txtDept.Text);
MyCommand.Parameters.Add("@h_staffno", txtStaff.Text);
MyCommand.Parameters.Add("@h_hp", "+6" + txtH.Text + txtP.Text);
MyCommand.Parameters.Add("@h_email", txtEmail.Text);
MyCommand.Parameters.Add("@h_day", txtDay.Text);
MyCommand.Parameters.Add("@h_date_apply", DateTime.Today.ToString());
MyCommand.ExecuteScalar();
MyConnection.Close();
MyConnection.Close();
Response.Redirect("aHolidayLeave.aspx?staff_id=" + Request.QueryString["staff_id"]);
}
Here's the related stored procedure
ALTER PROCEDURE dbo.StaffApplyLeave
(
@h_id int,
@sh_id int,
@h_name varchar(50),
@h_from datetime,
@h_till datetime,
@h_add varchar(50),
@h_post varchar(50),
@h_dept varchar(50),
@h_staffno varchar(10),
@h_hp varchar(12),
@h_email varchar(50),
@h_day int,
@h_date_apply datetime
)
AS
insert into holiday (h_id,sh_id,h_name,h_from, h_till, h_add, h_post, h_dept,h_staffno,h_hp,h_email,h_day, h_date_apply)
values(@h_id,@sh_id,@h_name,@h_from, @h_till, @h_add, @h_post, @h_dept,@h_staffno,@h_hp,@h_email, @h_day,@h_date_apply)
RETURN.
Plz help solving this. Tq
1 1190
HI,
protected void btnUpdate_Click(object sender, EventArgs e)
{
SqlConnection MyConnection;
SqlCommand MyCommand;
MyConnection = new SqlConnection();
MyConnection.ConnectionString =
ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
MyConnection.Open();
MyCommand = new SqlCommand("StaffApplyLeave", MyConnection);
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.Add("@h_id", Request.QueryString["h_id"]);
MyCommand.Parameters.Add("@sh_id", Request.QueryString["staff_id"]);
MyCommand.Parameters.Add("@h_name", txtName.Text);
MyCommand.Parameters.Add("@h_from", txtFrom.Text);
MyCommand.Parameters.Add("@h_till", txtTill.Text);
MyCommand.Parameters.Add("@h_add", txtA1.Text + txtA2.Text);
MyCommand.Parameters.Add("@h_post", txtPost.Text);
MyCommand.Parameters.Add("@h_dept", txtDept.Text);
MyCommand.Parameters.Add("@h_staffno", txtStaff.Text);
MyCommand.Parameters.Add("@h_hp", "+6" + txtH.Text + txtP.Text);
MyCommand.Parameters.Add("@h_email", txtEmail.Text);
MyCommand.Parameters.Add("@h_day", txtDay.Text);
MyCommand.Parameters.Add("@h_date_apply", DateTime.Today.ToString());
MyCommand.ExecuteScalar();
MyConnection.Close();
MyConnection.Close();
Response.Redirect("aHolidayLeave.aspx?staff_id=" + Request.QueryString["staff_id"]);
}
Here's the related stored procedure
ALTER PROCEDURE dbo.StaffApplyLeave
(
@h_id int,
@sh_id int,
@h_name varchar(50),
@h_from datetime,
@h_till datetime,
@h_add varchar(50),
@h_post varchar(50),
@h_dept varchar(50),
@h_staffno varchar(10),
@h_hp varchar(12),
@h_email varchar(50),
@h_day int,
@h_date_apply datetime
)
AS
insert into holiday (h_id,sh_id,h_name,h_from, h_till, h_add, h_post, h_dept,h_staffno,h_hp,h_email,h_day, h_date_apply)
values(@h_id,@sh_id,@h_name,@h_from, @h_till, @h_add, @h_post, @h_dept,@h_staffno,@h_hp,@h_email, @h_day,@h_date_apply)
RETURN.
Plz help solving this. Tq
I would think that making sure a value exists in Request.QueryString["h_id"] should suffice. If it's not passed, default it to some acceptable value.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alexander Pino |
last post by:
Hi,
does anyone know if, and how, I can return a record (set) from a stored
procedure/function?
What does the function have to do?
well at this moment I'm porting our product's database based...
|
by: Senthil |
last post by:
Hi,
I created a stored procedure in the sql server. I try to insert a record
from the aspx page. But I keep getting this error,
"procedure expects parameter <@firstname>, which was not...
|
by: jfturcott |
last post by:
Prepared statement '(@p1 int,@p2 tinyint,@p3 varchar(8000),@p4
varchar(8000),@p5 bit' expects parameter @p1, which was not supplied.
I get the above error when trying to update a datagridview to...
|
by: Maneesh Agarwal |
last post by:
I am trying to pass a parameter to dynamically populate drop down list. I am not able to pass the parameter from my .aspx file. Here is the grid view and related ObjectDataSource. In srcLocation, the...
|
by: preeti13 |
last post by:
i am trying to dispaly a datagrid but getting the erorr please any one help me with this.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page...
|
by: malayappa |
last post by:
Hi All
here is the error what i m getting
Warning: domdocument::domdocument() expects parameter 2 to be long, string given in D:\Program Files\Apache Software...
|
by: sumandak |
last post by:
I want to insert data from User Input to DB (MySQL 2005) using stored proc and a report to show the data which has one parameter at a time to view information.
I've tried for almost 2 weeks on...
|
by: dragos42 |
last post by:
m from Romania and I bought the book let yourself, bother with a problem to conduct script 14.2 appear:
The file has been uploaded!
Warning: mysqli_query() expects parameter 1 to be mysqli,...
|
by: BRawn |
last post by:
Hi,
I'm writing an application which needs SQL parameters to be passed, and even though I've assigned parameters to the stored procedure, I keep getting the following error message from the...
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |