Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have table billentry
column is token_no ppo_no billdate
2 1138 4/6/2014
3 11951 4/6/2014


now from combobox i have select ppo_no again 1138 so it will show 1138 is already in database in 4/6/2014
Posted
Updated 3-Jun-14 20:50pm
v2

 
Share this answer
 
try this.. :)

C#
string ppo_no = "Set ppo_no value"; //E.G. 1138
            string billDate = "Set billdate"; //E.G. 4/6/2014

            string DeleteStr = "select * from Tablename where ppo_no="+ppo_no+" and convert(varchar,billdate,106)=convert(varchar,"+billDate+",106)"; //You can set date format whatever you want
         
            SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionstringName"].ConnectionString);
            SqlCommand sql_cmd = new SqlCommand(DeleteStr, cn);
            cn.Open();
            DataTable dtGetData = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(sql_cmd);
            da.Fill(dtGetData);
            if (dtGetData.Rows.Count > 0)
            {
                //Data already exists.. :)

            }
            else
            { 
                //Data is not exists. :)
            
            }


            cn.Close();
            cn.Dispose();
            sql_cmd.Dispose();
 
Share this answer
 
Comments
tanugarg 4-Jun-14 2:45am    
not helpful

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