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
Israel
699
1.3k
215.7k
filter from two datetimepickers and place on click event
Jul 14 2018 4:11 PM
Hi,
These codes help me to have my graph in runtime and works well.
But I have two questions that can be simple for you (not for me because I need to learn) .
1. I am trying two make filter of two datetimepickers from my sql database. But it's doesnt result.
2. I would like to use these code on my button click's event: I do try to put it on a button but its gives error.
SqlConnection conn = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename=C:\\Flex1\\Flex2\\App_datas\\flex.mdf;Integrated Security = True");
SqlCommand comm;
string connstr = @"Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename=C:\\Flex1\\Flex2\\App_datas\\Flex.mdf;Integrated Security = True";
private void GraficoBarra_Load(object sender, EventArgs e)
{
fillChart();
}
private void fillChart()
{
SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Flex1\\Flex2\\App_datas\\Flex.mdf;Integrated Security=True");
DataSet ds = new DataSet();
con.Open();
SqlDataAdapter adapt = new SqlDataAdapter("select date,name,fonction from company where data between @StartDate and @EndDate '", con);
var param1 = new SqlParameter("@StartDate", SqlDbType.Date);
var param2 = new SqlParameter("@EndDate", SqlDbType.Date);
param1.Value = dateTimePicker1.Value.Date;
param2.Value = dateTimePicker2.Value.Date;
if (dateTimePicker2.Value <= dateTimePicker1.Value)
{
comm.Parameters.Add(param1);
comm.Parameters.Add(param2);
}
else
{
comm.Parameters.Add(param2);
comm.Parameters.Add(param1);
}
adapt.Fill(ds);
Test.DataSource = ds;
Test.Series["Test"].XValueMember = "name";
Test.Series["Test"].YValueMembers = "fonction";
Test.Titles.Add("Report");
con.Close();
}
Reply
Answers (
1
)
Code to print multiple employee salary on single click
unordered list dynamically