سلام بر تمامی برنامه نویسان عزیز 😉 در این پست آموزش افزودن محدودیت به DataTable با UniqueConstraint در سی شارپ #C را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
کد افزودن محدودیت به DataTable با UniqueConstraint در سی شارپ #C :
using System;
using System.Data;
class Program
{
static void Main(string[] args)
{
DataTable dt1 = new DataTable("Table-1");
DataColumn pkCol = dt1.Columns.Add("Id", typeof(int));
dt1.Columns.Add("Field1", typeof(string)).MaxLength = 50;
dt1.PrimaryKey = new DataColumn[] { pkCol };
using System.Data;
class Program
{
static void Main(string[] args)
{
DataTable dt1 = new DataTable("Table-1");
DataColumn pkCol = dt1.Columns.Add("Id", typeof(int));
dt1.Columns.Add("Field1", typeof(string)).MaxLength = 50;
dt1.PrimaryKey = new DataColumn[] { pkCol };