Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Data base Structure as follows in Ms Access;
 
Name Text
Day Text
 

Design as follows;
 
Name Combo box
Day Combo box
 
In the name column,all names retrieved from the database and display into the Combo box.
In the day column day from sunday to saturday is maually by coding.
 

in the run mode. when i select the Name and Day and click the save button. the records are saved in the database.
 

in the database records as follows
 
Suresh Sunday
Suresh Monday
 

i have one search button, when i click the search button, the above two records are displayed in the datagridview.
 
In the datagridview records as follows;
 
Name Day
Suresh Sunday
Suresh Monday
 
when i click the first record suresh in datagridview the particular record is display in to the combobox.
 
in that suppose i want to update the first record (suresh) sunday changed in to friday and click the update button.in the database for suresh all entries day is updated into friday. but i want to update the friday for the first reocord only.
 
output as follows;
 
Suresh Friday
Suresh Friday
 
But i want the ouput as follows after click the update butotn
 
Suresh Friday
Suresh Monday
 

how to update.for that how can i do using csharp.
 
please help me.
 
Regards & Thanks,
Narasiman P.
Posted 18-Feb-13 18:36pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Check your WHERE Clause in update Statement; condition should not be given by name. Instead use a Primary key in WHERE CLAUSE.
  Permalink  
v2
Comments
Member 8054539 at 19-Feb-13 1:39am
   
can i use name as primary key.suppose i set primary key as name,
 
the below entries is possible.
 
Suresh Monday
Suresh Friday
 
please help me.
 
thanks and Regards,
Vardhan Desai at 19-Feb-13 2:15am
   
No absolutely you cannot. Primary Key is a identifier for a record. Primary Key is better to be numeric.
Plz read the concept of Primary Key before implementation.
Vardhan Desai at 19-Feb-13 4:41am
   
Is it working now?
Member 8054539 at 19-Feb-13 7:19am
   
i don't know how to do?
 
i am trying the below thing as follows;
 
in the database can i add one column SNo.
 
And set the SNo to Primary key.
 
when i update, i use the above query as follows;
 
sql = "Update Tb_common_Holidays set [Day] = '" + cb_daysweek.Text + "' where SNO = '" + cb_id.Text + "' ";
 
The above Update query is correct and please help me.
 
but in design i won't show the SNO.
Only in Database SNO will be there.
 
For SNO i use datatype as Auto Number.
Vardhan Desai at 21-Feb-13 7:04am
   
Is your problem solved?
If with my slution then do 'Accept Solution'
Else let me know atlst.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Yeah. . . SNo should be Primary Key with datatype Numeric/Integer.
Fetch SNo in an Hiddenfield (Control from ToolBox) while listing the details.
used the same in Where Clause of Update Clause.
Initially Hiddenfield will be blank. And its Property is ".Value" to Save text in it.
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid