?????????????????????????
????1. ???????????
????2. ???sql???????????
????3. ???sql??????Transaction
????4. ???sql??????SqlTransaction
????5. ???DataAdapter
????6. ???TransactionScope??SqlBulkCopy
????7. ?????????
????????????SQL Server?????????
????create table TestTable
????(
????Id int
??????Name nvarchar(20)
????)
?????????????????DataTable??????????????????
1.public class Tools
2.{
3.    public static DataTable MakeDataTable()
4.    {
5.        DataTable table = new DataTable();
6.
7.        //????DataTable????(schema)
8.        table.Columns.Add("Id"?? Type.GetType("System.Int32"));
9.        table.Columns.Add("Name"?? Type.GetType("System.String"));
10.
11.        //????????
12.        table.PrimaryKey = new DataColumn[] { table.Columns["ID"] };
13.        table.Columns["Id"].AutoIncrement = true;
14.        table.Columns["Id"].AutoIncrementSeed = 1;
15.        table.Columns["Id"].ReadOnly = true;
16.        return table;
17.    }
18.
19.    public static void MakeData(DataTable table?? int count)
20.    {
21.        if (table == null)
22.            return;
23.
24.        if (count <= 0)
25.            return;
26.
27.        DataRow row = null;
28.
29.        for (int i = 1; i <= count; i++)
30.        {
31.            //????????μ?DataRow????(???????????)
32.            row = table.NewRow();
33.            row["Name"] = "Test" + i.ToString();
34.            //????μ?DataRow
35.            table.Rows.Add(row);
36.        }
37.    }
38.}
public class Tools
{
public static DataTable MakeDataTable()
{
DataTable table = new DataTable();
//????DataTable????(schema)
table.Columns.Add("Id"?? Type.GetType("System.Int32"));
table.Columns.Add("Name"?? Type.GetType("System.String"));
//????????
table.PrimaryKey = new DataColumn[] { table.Columns["ID"] };
table.Columns["Id"].AutoIncrement = true;
table.Columns["Id"].AutoIncrementSeed = 1;
table.Columns["Id"].ReadOnly = true;
return table;
}
public static void MakeData(DataTable table?? int count)
{
if (table == null)
return;
if (count <= 0)
return;
DataRow row = null;
for (int i = 1; i <= count; i++)
{
//????????μ?DataRow????(???????????)
row = table.NewRow();
row["Name"] = "Test" + i.ToString();
//????μ?DataRow
table.Rows.Add(row);
}
}
}