我有以下测试应用程序将更改推送到将添加和删除的字段压缩数字但我无法获得实际保存到SQL表的更改
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace TEST
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SqlConnection connString = new SqlConnection("Data Source=RMGIAX90; Initial Catalog=CredUAT; Integrated Security=True;");
int cnt = 0;
da.SelectCommand = new SqlCommand(@"SELECT * FROM ScanlineZonestopleft Order By ZoneOrder", connString);
da.Fill(ds, "ScanlineZonestopleft");
dt = ds.Tables["ScanlineZonestopleft"];
foreach (DataRow dr in dt.Rows)
{
dr["ZoneOrder"] = cnt;
cnt ++;
dr.AcceptChanges();
//MessageBox.Show(dr["ZoneOrder"].ToString());
}
MessageBox.Show("Update Complete");
}
}
}