using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;namespace login
{
    public partial class self : Form
    {
        string pname2;
        public self(string pname2)
        {
            InitializeComponent();            this.pname2 = pname2;
            SqlConnection sc = new SqlConnection("data source=.;initial catalog=WarehouseSystem;integrated security=sspi");
            sc.Open();
            SqlCommand cmd = new SqlCommand("select name from customer where pswd='" +pname2  + "'", sc);
            string name = cmd.ExecuteScalar().ToString();
            SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM customer where name ='"+name +"'", sc );            DataSet ds = new DataSet();
            da.Fill(ds , "customer");
            dataGridView1.DataSource = ds.Tables["customer"];            //然后用SqlCommandBuilder自动为SqlDataAdapter生成Insert、Update、Delete命令 
            SqlCommandBuilder sqlCmdBuilder = new SqlCommandBuilder(da );
        }        private void button1_Click(object sender, EventArgs e)
        {
            DataSet ds=new DataSet ();
            SqlDataAdapter da =new SqlDataAdapter ();
            if (ds.HasChanges())
            {
                try
                {
                    da.Update(ds.Tables["customer"]);
                    ds.Tables["customer"].AcceptChanges();
                    MessageBox.Show("更新成功!", "操作结果", MessageBoxButtons.OK, MessageBoxIcon.Information);                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "更新失败!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }        }在网上查到的这种方法自己却不好用  请问哪里有问题  其中表customer 中已设主键