Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am creating a form in .net windows application.And I have a table with the columns named as Name,Amount and Status.And In my front end, i have use two text boxes for Name and Amount columns respectively.And two checked boxes named as paid and not paid.
C#
private void button3_Click(object sender, EventArgs e)
{
   con.Open();
   SqlCommand cmd = new SqlCommand("insert into tablename (name,id) values('"+txtName.Text+"','"+txtId.Text+"')",con);
           cmd.ExecuteNonQuery();
           con.Close();
   }

By this code, i can save Name and ID in that corresponding columns.But in Status column, i should store either one value of checked box(either paid or not paid). For this kindly send me coding.

Thanks
Viswanathan.M
Posted
Updated 5-Aug-11 2:39am
v3

1 solution

First, the status column should be defined as boolean in the table.
Second, convert the checkbox value to true or false and then store that value into the table.

You query would be something like
insert into tablename (name,id,status) <br />
values<br />
(txtname,text,txtId.text, chkBox.checked)<br />
<br />
 
Share this answer
 
v2
Comments
Viswanthan.M. 5-Aug-11 8:28am    
Thank yu for reply.. can you send completely.
Abhinav S 5-Aug-11 8:38am    
Try this out.
Viswanthan.M. 5-Aug-11 9:34am    
I tried but i cant..
Viswanthan.M. 5-Aug-11 9:34am    
i tried..but i cant

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