TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rocky Rocky
NA
317
151.4k
what was Error in My code of Draft Items In c#?
Jul 18 2013 2:37 AM
Hai Naveen,
i made the code for draft in home.aspx page the if user save the content means ll display
gridview.
if sumother user logged in and see the home.aspx draft item means ll showing error like
"cannot find table 0"
here i paste my code:
=====================
public void draftdata()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["AccessConnectionString"].ConnectionString);
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand("drft", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@username",uname);
SqlDataAdapter da = new SqlDataAdapter(cmd);
//SqlDataReader rdrData;
ds.Clear();
da.Fill(ds);
con.Open();
cmd.ExecuteNonQuery();
//rdrData = cmd.ExecuteReader();
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
}
else
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
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";
}
con.Close();
}
that procedure is:
==================
alter procedure drft
(
@username varchar(20)
)
as
begin
declare @usercode varchar(20),
@request int
select @usercode=a.user_id ,@request=b.request_id from travel_request b inner join users a on a.user_id=b.user_id where a.username= @username
if exists(select * from travel_request where user_id=@usercode)
begin
select
convert(varchar,min(a.departuredate),106) as Departuredate,
b.purpose_of_travel,
b.total_amount,
a.request_id,
b.user_id
from
travel_request b
inner join
onward_journey a
on
a.request_id = b.request_id
where
b.user_id=@usercode
and
a.request_id=@request
group by
b.purpose_of_travel,
b.total_amount,
a.request_id,
b.user_id
end
end
let me back was error in that?
Reply
Answers (
2
)
how to work on datalist with paging using filter and sort
Connect to sql server from anothe PC