Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 11:37 PM EDT
SELECT @requestId as requestId
Regards,
Iftikar
Sunny SharmaRank #223 · 11.1K reputationPosted Jul 25, 2013, 10:03 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 10:13 PM EDT
Please provide more details If possible then attach the screen shot.
Regards,
Iftikar
Rocky RockyRank #7,391 · 242 reputationPosted Jul 25, 2013, 10:26 PM EDT
for The ADD button i made the code like below
protected void ADD_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("[Insert_Journey]", conn);
datecheck();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@departuredate", Datepicker.Text);
cmd.Parameters.AddWithValue("@from_location", TxtFm.Text);
cmd.Parameters.AddWithValue("@to_location", TxtTo.Text);
cmd.Parameters.AddWithValue("@metro", DDL_Metro.Text);
cmd.Parameters.AddWithValue("@trans_all", DDL_trans.Text);
cmd.Parameters.AddWithValue("@mode_of_travel", DDL_ModeOfTravel.Text);
cmd.Parameters.AddWithValue("@seat_type", DDL_SeatType.Text);
cmd.Parameters.AddWithValue("@no_of_days", TxtNo.Text);
cmd.Parameters.AddWithValue("@other_details", Txtothrdet.Text);
cmd.Parameters.AddWithValue("@status_id", Txtstts.Text);
cmd.Parameters.AddWithValue("@request", Txtrequest.Text);
conn.Open();
cmd.ExecuteNonQuery();
DateTime val = new DateTime();
DateTime b = new DateTime();
val = Convert.ToDateTime(Datepicker.Text);
b = val.AddDays(Convert.ToInt32(TxtNo.Text));
Datepicker.Text = b.ToString();
}
For My Procedure:
===============
--sp_helptext'insert_journey'
alter procedure Insert_Journey
(
@departuredate datetime,
@from_location varchar(50),
@to_location varchar(50),
@metro nvarchar(50),
@trans_all nvarchar(50),
@mode_of_travel nvarchar(50),
@seat_type nvarchar(50),
@no_of_days int,
@other_details varchar(50),
@status_id int,
@request int
)
as
BEGIN
DECLARE @MaxDate datetime
SELECT @MaxDate = MAX(DepartureDate) FROM onward_journey where request_id=IDENT_CURRENT ('travel_request')
IF(@MaxDate >@departuredate)
begin
RAISERROR('Your error message for departuredate should be greater then maxdate',16,1)
RETURN
END
insert into onward_journey(departuredate,from_location,to_location,metro,trans_all,mode_of_travel,seat_type,no_of_days,other_details,status_id,request_id) values(@departuredate,@from_location,@to_location,@metro,@trans_all,@mode_of_travel,@seat_type,@no_of_days,@other_details,'2',IDENT_CURRENT ('travel_request'))
--set @request= IDENT_CURRENT ('travel_request')
--return @request
end
--
Now My the problem is when i add the values gridview not shown...............
public void binddata()
{
if ((TxtComments.Text == "") && (Txttotal.Text == ""))
{
string req = Txtrequest.Text;
string strquery = "select
onward_journey_id,
convert(varchar, departuredate, 106)as DepartureDate,
from_location,
to_location,
case metro when 'Yes' then 'Yes' else 'No' end as Metro,
case Trans_All when 'Yes' then 'Yes' else 'No' END as transit,
no_of_days as noofdays,
other_details
from
onward_journey
where request_id=IDENT_CURRENT ('travel_request') order by departuredate";
SqlCommand cmd = new SqlCommand(strquery, conn);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
ds.Clear();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
}
else
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
GridView1.DataSource = ds;
GridView1.DataBind();
int columncount = GridView1.Rows[0].Cells.Count;
GridView1.Rows[0].Cells.Clear();
GridView1.Rows[0].Cells.Add(new TableCell());
GridView1.Rows[0].Cells[0].ColumnSpan = columncount;
GridView1.Rows[0].Cells[0].Text = "No Records Found";
}
conn.Close();
}
}
above BINDATA() function ll reflect the grid vieaw table what was problem in that?
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 10:46 PM EDT
Regards,
Iftikar
Rocky RockyRank #7,391 · 242 reputationPosted Jul 25, 2013, 11:04 PM EDT
when i choose
select * from onward_journey where request_id= IDENT_current('Travel_request).
after the save the gridview value other login person try to add new details gridview view showing previous gridview value's.
depends upon the person ll show empty doesn't older value in gridview...... how to do that?
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 11:15 PM EDT
You are doing like this
1. Creating Travel Request (i.e. travel_request table entry)
2. Creating Onward Journey details (i.e. onward_journey table entry)
each travel travel request there will be one entry in the second table
Regards,
Iftikar
Rocky RockyRank #7,391 · 242 reputationPosted Jul 25, 2013, 11:26 PM EDT
your are correct
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 11:30 PM EDT
Regards,
Iftikar
Rocky RockyRank #7,391 · 242 reputationPosted Jul 25, 2013, 11:32 PM EDT
(
@user varchar(100),
@purpose varchar(100),
@adamt varchar(10),
@status int,
@total varchar(100)
)
as
begin
if not exists (select * from travel_request where user_id=@user and purpose_of_travel=@purpose and advance_amount=@adamt and status_id=@status)
insert into travel_request (user_id,purpose_of_travel,advance_amount,status_id,total_amount) values(@user,@purpose,@adamt,'2',@total)
end
Rocky RockyRank #7,391 · 242 reputationPosted Jul 25, 2013, 11:50 PM EDT
when i am trying to insert dates via front hand its wont accepting what is the problem in that?
code is already written above "ADD_CLICK".
can you guide me and one more think gridview doestnot show any values.......
what can i do?
protected void ADD_CLICK(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("[Insert_Journey]", conn);
datecheck();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@departuredate", Datepicker.Text);
cmd.Parameters.AddWithValue("@from_location", TxtFm.Text);
cmd.Parameters.AddWithValue("@to_location", TxtTo.Text);
cmd.Parameters.AddWithValue("@metro", DDL_Metro.Text);
cmd.Parameters.AddWithValue("@trans_all", DDL_trans.Text);
cmd.Parameters.AddWithValue("@mode_of_travel", DDL_ModeOfTravel.Text);
cmd.Parameters.AddWithValue("@seat_type", DDL_SeatType.Text);
cmd.Parameters.AddWithValue("@no_of_days", TxtNo.Text);
cmd.Parameters.AddWithValue("@other_details", Txtothrdet.Text);
cmd.Parameters.AddWithValue("@status_id", Txtstts.Text);
// cmd.Parameters.AddWithValue("@request", Txtrequest.Text);
conn.Open();
cmd.ExecuteNonQuery();
DateTime val = new DateTime();
DateTime b = new DateTime();
val = Convert.ToDateTime(Datepicker.Text);
b = val.AddDays(Convert.ToInt32(TxtNo.Text));
Datepicker.Text = b.ToString();
binddata();
}
/// here how to get the request for shall i un marked that or market that date cannot be inserting?
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 26, 2013, 12:50 AM EDT
cmd.Parameters.AddWithValue("@departuredate", string.Format("{0:MM/dd/yyyy}", Datepicker.Value));
Regards,
Iftikar
Rocky RockyRank #7,391 · 242 reputationPosted Jul 26, 2013, 1:06 AM EDT
After change travel_request its working fine.Thank you so much friend