Не удается увеличить значения базы данных
я хочу увеличивать значение базы данных с каждым нажатием кнопки.
Что я уже пробовал:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.SqlClient; namespace online_test { public partial class Form1 : Form { int incre = 0; public Form1() { InitializeComponent(); radioButton1.TabStop = false; radioButton2.TabStop = false; radioButton3.TabStop = false; radioButton4.TabStop = false; //qn1(); } private void Form1_Load(object sender, EventArgs e) { //string source_1 = @"DataSource=(LocalDB)\MSSQLLocalDB;" + @"AttachDbFilename=C: \Users\NASH\Documents\Visual Studio 2015\Projects\C#\online test\online test\Database1.mdf;" + "Integrated Security=True;" + "database=<test.mdf';"; string source_1 = @"Data Source = (LocalDB)\MSSQLLocalDB;" + @"AttachDbFilename=C:\Users\NASH\Documents\Visual Studio 2015\Projects\C#\online test\online test\test.mdf;" + "Integrated Security = True"; SqlConnection Con_1 = new SqlConnection(source_1); { Con_1.Open(); MessageBox.Show("connected to db"); String sqlSelectQuery = @"SELECT * FROM[Table]"; SqlCommand cmd = new SqlCommand(sqlSelectQuery, Con_1); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { //incre++; { label2.Text = (dr["Question"].ToString()); textBox1.Text = (dr["sl"].ToString()); radioButton1.Text = (dr["Option A"].ToString()); radioButton2.Text = (dr["Option B"].ToString()); radioButton3.Text = (dr["Option C"].ToString()); radioButton4.Text = (dr["Option D"].ToString()); } incre = Convert.ToInt32(textBox1.Text); // incre++; // @"SELECT * FROM[Table]WHERE sl=",incre; } Con_1.Close(); } } //button1_click is next button private void button1_Click(object sender, EventArgs e) { incre++; String sqlSelectQuery = @"SELECT * FROM[Table] WHERE sl=incre"; if (dr.Read()) { //incre++; { label2.Text = (dr["Question"].ToString()); textBox1.Text = (dr["sl"].ToString()); radioButton1.Text = (dr["Option A"].ToString()); radioButton2.Text = (dr["Option B"].ToString()); radioButton3.Text = (dr["Option C"].ToString()); radioButton4.Text = (dr["Option D"].ToString()); } } // button3_click is previous button private void button3_Click(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } } }