Hi all,

still relatively new to c# and asp.net.

Can anyone tell me what I'm doing wrong here:

string updateSql = "UPDATE FirstData " + "SET numplay=numplay+1 " + "WHERE PlayerNum = @PlayerNum";
            SqlCommand UpdateCmd = new SqlCommand(updateSql, thisConnection);
            UpdateCmd.Parameters.Add("@PlayerNum", SqlDbType.Int,10, "PlayerNum");
            //UpdateCmd.Parameters.Add("@numaddval", SqlDbType.Int,10, "[numplay]");
            UpdateCmd.Parameters["@PlayerNum"].Value = "2";
            UpdateCmd.Transaction = trans1; 
            UpdateCmd.ExecuteNonQuery();
            trans1.Commit();

I am trying to update an integer column of a database file table by just 1 - when a button is clicked, a column cell increments by 1. Simple, but can't seem to do successfully.


Any ideas from the gurus here?

Invoke Commit transaction method.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.