重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

DataTable设置自增标识列的异常

public DataSet GetProviderTypeDs()
        {
            using (SqlConnection con = new SqlConnection(this.conStr))
            {
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = @"select * from ProviderType";
                con.Open();
                SqlDataAdapter ada = new SqlDataAdapter(cmd);
                ada.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                DataSet ds = new DataSet();
                ada.Fill(ds,"ProviderType");
                
                //先设置seed再设置step导致seed设置失败,seed被设置为Table的标识列ID最大值
                //ds.Tables[0].Columns[0].AutoIncrementSeed = -1;
                //ds.Tables[0].Columns[0].AutoIncrementStep = -1;
                
                
                ds.Tables[0].Columns[0].AutoIncrementStep = -1;
                ds.Tables[0].Columns[0].AutoIncrementSeed = -1;
                
                ds.Tables[0].Columns[0].ReadOnly = false;
                return ds;
            }
        }

分享名称:DataTable设置自增标识列的异常
标题链接:http://cqcxhl.com/article/pojice.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP