Repository navigation
Expand file tree
/
Copy pathColumn.cs
More file actions
74 lines (67 loc) · 2.05 KB
/
Copy pathColumn.cs
File metadata and controls
74 lines (67 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlServerExport
{
class Column
{
public string Type;
public int Ordinal;
public int Length;
public string Name;
public bool IsNullable;
public string FormatData(object Data)
{
if (Data == DBNull.Value)
{
return "NULL";
}
switch (Type)
{
case "int":
return Data.ToString();
case "nvarchar":
return "'" + Data.ToString().Replace("'", "''") + "'";
case "ntext":
return "'" + Data.ToString().Replace("'", "''") + "'";
case "datetime":
return "'" + Convert.ToDateTime(Data).ToString("MMM dd yyyy hh:mm:sstt") + "'";
default:
return Data.ToString();
}
}
public string GetDefintion()
{
StringBuilder Definition = new StringBuilder();
Definition.Append("[" + Name + "] ");
switch (Type)
{
case "int":
Definition.Append(Type + " ");
break;
case "nvarchar":
Definition.Append(Type + "(" + Length.ToString() + ") ");
break;
case "ntext":
Definition.Append(Type + " ");
break;
case "datetime":
Definition.Append(Type + " ");
break;
default:
Definition.Append(Type + " ");
break;
}
if (IsNullable)
{
Definition.Append("NULL");
}
else
{
Definition.Append("NOT NULL");
}
return Definition.ToString();
}
}
}