Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

Check your WHERE Clause in update Statement; condition should not be given by name. Instead use a Primary key in WHERE CLAUSE.
 
Share this answer
 
v2
Comments
[no name] 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,
MalwareTrojan 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.
MalwareTrojan 19-Feb-13 4:41am    
Is it working now?
[no name] 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.
MalwareTrojan 21-Feb-13 7:04am    
Is your problem solved?
If with my slution then do 'Accept Solution'
Else let me know atlst.
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.
 
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