-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParameter.cs
112 lines (75 loc) · 5.4 KB
/
Parameter.cs
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System.Data.SqlClient;
using System.Data;
public class SQLDBParameter
{
public enum SqlDatabaseType
{
SqlBigInt = SqlDbType.BigInt,
SqlBinary = SqlDbType.Binary,
SqlBit = SqlDbType.Bit,
SQLChar = SqlDbType.Char,
SQLDate = SqlDbType.DateTime,
SQLDateTime = SqlDbType.DateTime,
SQLDecimal = SqlDbType.Decimal,
SQLFloat = SqlDbType.Float,
SQLImage = SqlDbType.Image,
SQLInt = SqlDbType.Int,
SQLMoney = SqlDbType.Money,
SQLNChar = SqlDbType.NChar,
SQLNText = SqlDbType.NText,
SQLNVarChar = SqlDbType.NVarChar,
SQLReal = SqlDbType.Real,
SQLSmallDateTime = SqlDbType.SmallDateTime,
SQLSmallInt = SqlDbType.SmallInt,
SQLSmallMoney = SqlDbType.SmallMoney,
SQLText = SqlDbType.Text,
SQLTimestamp = SqlDbType.Timestamp,
SQLTinyInt = SqlDbType.TinyInt,
SQLUdt = SqlDbType.Udt,
SQLUniqueIdentifier = SqlDbType.UniqueIdentifier,
SQLVarBinary = SqlDbType.VarBinary,
SQLVarChar = SqlDbType.VarChar,
SQLVariant = SqlDbType.Variant,
SQLXml = SqlDbType.Xml
}
public static SqlParameter CreateParameter(string ParameterName, SqlDbType DBType)
{
SqlParameter objParameter = new SqlParameter();
objParameter.ParameterName = ParameterName;
objParameter.SqlDbType = DBType;
objParameter.Direction = ParameterDirection.Output;
return objParameter;
}
public static SqlParameter CreateParameter(string ParameterName, SqlDbType DBType, object Value)//, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(0)] // ERROR: Optional parameters aren't supported in C# int Size, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(ParameterDirection.Input)] // ERROR: Optional parameters aren't supported in C# ParameterDirection Direction, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(true)] // ERROR: Optional parameters aren't supported in C# bool isNullable, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(0)] // ERROR: Optional parameters aren't supported in C# byte Precision, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(0)] // ERROR: Optional parameters aren't supported in C# byte Scale, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")] // ERROR: Optional parameters aren't supported in C# string SourceColumn, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(DataRowVersion.Default)] // ERROR: Optional parameters aren't supported in C# DataRowVersion SourceVersion )
{
SqlParameter objParameter = new SqlParameter();
objParameter.ParameterName = ParameterName;
objParameter.SqlDbType = DBType;
objParameter.Value = Value;
return objParameter;
}
public static SqlParameter CreateParameter(string ParameterName, SqlDbType DBType, object Value, ParameterDirection Direction, int Size)//, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(0)] // ERROR: Optional parameters aren't supported in C# int Size, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(ParameterDirection.Input)] // ERROR: Optional parameters aren't supported in C# ParameterDirection Direction, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(true)] // ERROR: Optional parameters aren't supported in C# bool isNullable, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(0)] // ERROR: Optional parameters aren't supported in C# byte Precision, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(0)] // ERROR: Optional parameters aren't supported in C# byte Scale, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")] // ERROR: Optional parameters aren't supported in C# string SourceColumn, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(DataRowVersion.Default)] // ERROR: Optional parameters aren't supported in C# DataRowVersion SourceVersion )
{
SqlParameter objParameter = new SqlParameter();
objParameter.ParameterName = ParameterName;
objParameter.SqlDbType = DBType;
if (Size != 0)
{
objParameter.Size = Size;
}
if (Direction != ParameterDirection.Input)
{
objParameter.Direction = Direction;
}
objParameter.Value = Value;
return objParameter;
}
public static SqlParameter CreateParameter(string ParameterName)
{
SqlParameter objParameter = new SqlParameter();
objParameter.ParameterName = ParameterName;
//objParameter.SqlDbType = SqlDbType
objParameter.Direction = ParameterDirection.Output;
return objParameter;
}
}