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
dhanu sahu
NA
4
0
Error.Conversion failed when converting the varchar value 'April' to data type int. C# .net
Apr 9 2008 2:06 AM
Hi Friends,My problem till Same Unsolved(months,year is varchar)I want to filter my data according to month and year in supply
protected void BtnSubmit_Click(object sender, EventArgs e)
{
int TotTime = Convert.ToInt32(Endtime.SelectedValue) - Convert.ToInt32(Sttime.SelectedValue);
SqlCommand sqlcmd = new SqlCommand("insert into D_TimeSheet1(EmpId,attDate,AttIn,AttOut,AttDay,TotalTime,Remarks,CreatedOn,Task,Months,Day,Year) VALUES ('" + Session["usid"].ToString() + "','" + lbldate.Text + "','" + Sttime.SelectedItem.Text + "','" + Endtime.SelectedItem.Text + "','" + lblday.Text + "','" + TotTime + "','" + txtremark.Text + "','" + DateTime.Now.ToString() + "','" + TextBox1.Text + "','" + Label2.Text + "','" + Label1.Text + "','" + Label3.Text + "')", new SqlConnection(strcon));
sqlcmd.Connection.Open();
sqlcmd.ExecuteNonQuery();
sqlcmd.Connection.Close();
Bindgrid();
}
public void Bindgrid()
{
string strsql="select * from D_TimeSheet1 where EmpId="+Session ["usid"]+" AND Months="+date .Month +" AND Year="+date .Year +" order By AttDate DESC";
string strcount = "select count(*) from D_TimeSheet1 where EmpId=" + Session["usid"] + " AND Months=" + Convert .ToInt32 ( date.Month )+ " AND year=" + date.Year + "";
SqlCommand cmd = new SqlCommand(strsql, new SqlConnection(strcon));
SqlCommand cmdcount = new SqlCommand(strcount, new SqlConnection(strcon));
cmd.Connection.Open();
cmdcount.Connection.Open();
...................................................................................................................................
int rownos =Convert.ToInt32 ( cmdcount.ExecuteScalar().ToString ());
....................................................................................................................................
if (rownos > 0)
{
GVTime.DataSource = cmd.ExecuteReader();
GVTime.DataBind();
}
cmd.Connection.Close();
cmdcount.Connection.Close();
string strcount1 = "select count(*) from D_TimeSheet1 where EmpId=" + Session["usid"] + " AND Months=" + date.Month + " AND year=" + date.Year + "";
SqlCommand cmdcount1 = new SqlCommand(strcount1, new SqlConnection(strcon));
cmdcount1.Connection.Open();
int rownos1 =Convert .ToInt32 ( cmdcount1.ExecuteScalar());
if (rownos1 > 0)
{
BtnSubmit.Enabled = false;
}
}
Reply
Answers (
1
)
windows service in vs2008
Invalid column name 'Jan'.Same for All months