Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
con.Open();
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from Sawdusts where dateno between('" + dateTimePicker1.Value + "' AND '" + dateTimePicker2.Value + "')";
           // cmd.ExecuteNonQuery();
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();

            da.Fill(ds);
            dataGridView2.DataSource = ds.Tables[0]; 
            con.Close();



Posted
Updated 15-Sep-15 0:24am
v2
Comments
Mehdi Gholam 15-Sep-15 3:55am    
... and what is the problem?
Mahendrangood@gmail.com 15-Sep-15 4:20am    
yes that is not working

i don't know that coding plz help me i feel to share that screen short how to upload that?
Naveen.Sanagasetti 15-Sep-15 3:59am    
Are you getting any error.? Please share your error details to us, so that we will help you as our best.
Mahendrangood@gmail.com 15-Sep-15 4:20am    
yes that is not working

i don't know that coding plz help me i feel to share that screen short how to upload that?
Naveen.Sanagasetti 15-Sep-15 5:23am    
Have you debug the code and check the same.?
What's the CommandText, and execute that commandtext in SQL Management studio and see the result set.

1 solution

When generating string queries for sql, dates should be in yyyy-mm-dd format (note the dash '-' instead of forward slash '/').

Better still use parameterized queries, read the following : http://stackoverflow.com/questions/3966094/passing-parameter-of-c-sharp-datetime-to-sql-server-2005[^]
 
Share this answer
 
Comments
Mahendrangood@gmail.com 15-Sep-15 5:00am    
i already create database and that table name "Sawdusts" that table details...

dateno
Name
ContactNumber
Address
VehicleNumber
EmptyWeight
LoadWeight
NetWeight
RatebyTon
Payment
TotalAmount
AdvanceAmount
ACredit
ADebit
BalanceAmount
BCredit
BDebit

now am using c# windows app

dataGridView1

i need date to date option like bank statement last 6 month

i dont know to put coding plz help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900