By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,899 Members | 1,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,899 IT Pros & Developers. It's quick & easy.

how to update a specific cell of a table ?

P: 16
hello all , i want to modify(update)a cell table. i have a website like a poll , and i want to modify dhe numbers of vote every time someone vote that item .. pls give me an idea or some code !!

Expand|Select|Wrap|Line Numbers
  1.  SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"].ConnectionString);
  2.         con.Open();
  3.         string Vote = "SELECT Project FROM projecttble WHERE Project = ('"+ RadioButtonList1.SelectedValue +"')";
  4.        SqlCommand cmd1 = new SqlCommand( Vote ,con );
  5.         string cmd3 = cmd1.ExecuteScalar().ToString();
  6.       Label1.Text = cmd3;
  7.  
  8.       string shtoVote1 = "SELECT Nr_votave FROM Tabela_projekteve WHERE Project = ('" + RadioButtonList1.SelectedValue + "')";
  9.       SqlCommand comand = new SqlCommand(shtoVote1, con);
  10.       string str1 = comand.ExecuteScalar().ToString();
  11.       int  str2 = int.Parse(str1) + 1;
  12.       Label2.Text = str2.ToString();
  13.  
  14.       string voto = "UPDATE Tabela_projekteve SET Nr_votave=@('"+str2+"'), Address=@NewAddress" +
  15.                     " WHERE Id=@Id ";
  16.  
  17.         con.Close();
  18.  
May 25 '13 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,359
I don't see any reference to a table cell in your code. Do you mean a field in a row of a table in your database? It looks like you already have the code for that.
May 25 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.