Click here to Skip to main content
15,883,769 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In run mode as follows


From date calendar1

In Table record as follows
Schdate   course   Staff   Active
28 Aug 14   MFA    BJR       A
29 Aug 14   EFA    RPK       A



When i click the From date i want to check for selected date record is there in the database.

suppose user select the 28 aug 14 in the calendar1, check whehter for selected 28 aug 14 record is there in the database.

if there shows the message for the selected date records is there.

suppose for selected date record is there want to Active 'A' in to 'D' want to upate

Then after inserting the record.

for that how can i validate in asp.net using c#

Regards,
Narasiman P.
Posted
Updated 1-Sep-14 23:15pm
v2
Comments
OriginalGriff 2-Sep-14 3:16am    
And?
What have you tried?
Where are you stuck?
[no name] 2-Sep-14 3:20am    
Update your question so that any one can help you

In Table record as follows
Schdate   course Staff Active
28 Aug 14   MFA   BJR   A
29 Aug 14   EFA   RPK   A



When i click the From date i want to check for selected date record is there in the database.

To check the existence of the record use the query:
C#
SqlCommand cmd;
SqldataAdapter adpt = new SqlDatAdapter("select count(*) from tablename where Schdate='28-Aug-14'",cn);
DataSet ds = new DataSet();
adpt.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
   Response.Write("Record Exists");
   for (int i=0;i<ds.tables[0].rows.count;i++)>
   {
      cmd = new SqlCommand("update tablename set Active='D' where Staff = '" + ds.Tables[0].Rows[i][2].ToString() + "'",cn);
      cn.Open();
      cmd.ExeceuteNonQuery();
      cn.Close();
      cmd.Dispose();
   }
}
else
{
   Response.Write("Record Not Exists");
}
 
Share this answer
 
v2
Comments
Nelek 2-Sep-14 5:16am    
Please get used to use the proper "code" language when posting snippets. It will make it easier to read.
To check if a record exists in the Db you can use a simple 'if exists' SQL

To insert or update records you can do a simple Update ..Where or a simple Insert (you've already checked if it exists)
 
Share this answer
 

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