@ -0,0 +1,62 @@ |
|||||
|
|
||||
|
Microsoft Visual Studio Solution File, Format Version 12.00 |
||||
|
# Visual Studio 14 |
||||
|
VisualStudioVersion = 14.0.25420.1 |
||||
|
MinimumVisualStudioVersion = 10.0.40219.1 |
||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagConfig", "TagConfig\TagConfig.csproj", "{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}" |
||||
|
EndProject |
||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataHelper", "..\Program\DataHelper\DataHelper.csproj", "{755C5459-BCA4-4729-A93C-0C73A41BDF3C}" |
||||
|
EndProject |
||||
|
Global |
||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
|
Debug|Any CPU = Debug|Any CPU |
||||
|
Debug|Itanium = Debug|Itanium |
||||
|
Debug|Mixed Platforms = Debug|Mixed Platforms |
||||
|
Debug|x64 = Debug|x64 |
||||
|
Debug|x86 = Debug|x86 |
||||
|
Release|Any CPU = Release|Any CPU |
||||
|
Release|Itanium = Release|Itanium |
||||
|
Release|Mixed Platforms = Release|Mixed Platforms |
||||
|
Release|x64 = Release|x64 |
||||
|
Release|x86 = Release|x86 |
||||
|
EndGlobalSection |
||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|Any CPU.ActiveCfg = Debug|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|Itanium.ActiveCfg = Debug|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|Mixed Platforms.Build.0 = Debug|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|x64.ActiveCfg = Debug|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|x86.ActiveCfg = Debug|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|x86.Build.0 = Debug|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|Any CPU.ActiveCfg = Release|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|Itanium.ActiveCfg = Release|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|Mixed Platforms.ActiveCfg = Release|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|Mixed Platforms.Build.0 = Release|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|x64.ActiveCfg = Release|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|x86.ActiveCfg = Release|x86 |
||||
|
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|x86.Build.0 = Release|x86 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Debug|Itanium.ActiveCfg = Debug|Itanium |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Debug|Itanium.Build.0 = Debug|Itanium |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Debug|Mixed Platforms.Build.0 = Debug|x86 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Debug|x64.ActiveCfg = Debug|x64 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Debug|x64.Build.0 = Debug|x64 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Debug|x86.ActiveCfg = Debug|x86 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Debug|x86.Build.0 = Debug|x86 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Release|Itanium.ActiveCfg = Release|Itanium |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Release|Itanium.Build.0 = Release|Itanium |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Release|Mixed Platforms.ActiveCfg = Release|x86 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Release|Mixed Platforms.Build.0 = Release|x86 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Release|x64.ActiveCfg = Release|x64 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Release|x64.Build.0 = Release|x64 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Release|x86.ActiveCfg = Release|x86 |
||||
|
{755C5459-BCA4-4729-A93C-0C73A41BDF3C}.Release|x86.Build.0 = Release|x86 |
||||
|
EndGlobalSection |
||||
|
GlobalSection(SolutionProperties) = preSolution |
||||
|
HideSolutionNode = FALSE |
||||
|
EndGlobalSection |
||||
|
EndGlobal |
||||
@ -0,0 +1,74 @@ |
|||||
|
using System.Data; |
||||
|
using System.IO; |
||||
|
using System.Text; |
||||
|
using System.Text.RegularExpressions; |
||||
|
|
||||
|
namespace TagConfig |
||||
|
{ |
||||
|
public static class DataConvert //:MarshalByRefObject
|
||||
|
{ |
||||
|
public static DataTable ConvertTextToTable(string str) |
||||
|
{ |
||||
|
if (string.IsNullOrEmpty(str)) return null; |
||||
|
DataTable mydt = new DataTable(""); |
||||
|
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(str))) |
||||
|
{ |
||||
|
using (var mysr = new StreamReader(stream)) |
||||
|
{ |
||||
|
string strline = mysr.ReadLine(); |
||||
|
string[] aryline = strline.Split('\t'); |
||||
|
for (int i = 0; i < aryline.Length; i++) |
||||
|
{ |
||||
|
aryline[i] = aryline[i].Replace("\"", ""); |
||||
|
mydt.Columns.Add(new DataColumn(aryline[i] + i)); |
||||
|
} |
||||
|
int intColCount = aryline.Length; |
||||
|
while ((strline = mysr.ReadLine()) != null) |
||||
|
{ |
||||
|
aryline = strline.Split('\t'); |
||||
|
DataRow mydr = mydt.NewRow(); |
||||
|
for (int i = 0; i < intColCount; i++) |
||||
|
{ |
||||
|
mydr[i] = aryline[i].Replace("\"", ""); |
||||
|
} |
||||
|
mydt.Rows.Add(mydr); |
||||
|
} |
||||
|
return mydt; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static DataTable ConvertCSVToTable(string str) |
||||
|
{ |
||||
|
DataTable mydt = new DataTable(""); |
||||
|
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(str))) |
||||
|
{ |
||||
|
using (var mysr = new StreamReader(stream)) |
||||
|
{ |
||||
|
string strline = mysr.ReadLine(); |
||||
|
|
||||
|
Regex reg = new Regex(@",(?=(?:[^\""]*\""[^\""]*\"")*(?![^\""]*\""))"); |
||||
|
string[] aryline = reg.Split(strline); |
||||
|
for (int i = 0; i < aryline.Length; i++) |
||||
|
{ |
||||
|
aryline[i] = aryline[i].Replace("\"", ""); |
||||
|
mydt.Columns.Add(new DataColumn(aryline[i])); |
||||
|
} |
||||
|
int intColCount = aryline.Length; |
||||
|
while ((strline = mysr.ReadLine()) != null) |
||||
|
{ |
||||
|
aryline = reg.Split(strline); |
||||
|
|
||||
|
DataRow mydr = mydt.NewRow(); |
||||
|
for (int i = 0; i < intColCount; i++) |
||||
|
{ |
||||
|
mydr[i] = aryline[i].Replace("\"", ""); |
||||
|
} |
||||
|
mydt.Rows.Add(mydr); |
||||
|
} |
||||
|
return mydt; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 127 B |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
|
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 104 B |
|
Before Width: | Height: | Size: 894 B After Width: | Height: | Size: 894 B |
|
Before Width: | Height: | Size: 85 B After Width: | Height: | Size: 85 B |
|
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 342 B After Width: | Height: | Size: 342 B |
|
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 107 B |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |
|
Before Width: | Height: | Size: 894 B After Width: | Height: | Size: 894 B |
|
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 120 B |
|
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 894 B After Width: | Height: | Size: 894 B |
|
Before Width: | Height: | Size: 626 B After Width: | Height: | Size: 626 B |
|
Before Width: | Height: | Size: 894 B After Width: | Height: | Size: 894 B |
|
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 117 B |
|
Before Width: | Height: | Size: 894 B After Width: | Height: | Size: 894 B |
@ -0,0 +1,82 @@ |
|||||
|
6.9.10 |
||||
|
- Added user contribution in bug MySql.Web.Security.CreateUserInUserTable does not work (MySQL Bug #83656, Oracle Bug # 25046364). |
||||
|
- Fixed incorrect encoding in connection passwords (MySQL Bug #80611, Oracle Bug #23257011). |
||||
|
|
||||
|
|
||||
|
6.9.9 |
||||
|
- Fix for Nested transactions are not supported in Entity Framework (MySQL Bug #71502, Oracle Bug #22366266). |
||||
|
- Fix for EF5 and EF6 wrong SQL statement to set primary key (MySQL Bug 76292, Oracle Bug #20711384) |
||||
|
- Fixed problem where mysql.proc tables would not be used for metadata even though access was available (MySQL Bug #74116, Oracle Bug #20960373) |
||||
|
- Added support for TLSv1.1 and TLSv1.2 |
||||
|
- Fixed Fix for "Aborted connection" (MySQL Bug #80997, Oracle Bug # 23346197). |
||||
|
|
||||
|
|
||||
|
6.9.8 |
||||
|
- Added support for Chinese character set gb18030. (Oracle bug # 21098546). |
||||
|
- Added support for Json type. (WL # 8132). |
||||
|
- Added changes for metadata information in generated columns with 5.7 (WL #411) |
||||
|
|
||||
|
6.9.7 |
||||
|
- Changed default SSL mode to Preferred in connection string. Now the server connections will be using SSL if server allows it by default but it's possible to override this configuration. |
||||
|
- Changed handshake process to use bytes instead of encoded strings. |
||||
|
- Fix for Fabric connections (Oracle Bug #20983968). |
||||
|
- Fix for Fabric plugin: fabric server selection is broken when master is faulty (Oracle Bug #21203824). |
||||
|
|
||||
|
|
||||
|
6.9.6 |
||||
|
- Fix for Incorrect query result with Entity Framework 6 (MySql bug #74918, Oracle bug #20129927). |
||||
|
- Fix for GetTimeZoneOffset to use date and time to calculate timediff (MySQL Bug #74905, Oracle Bug #20065691). |
||||
|
- Fix for MySqlSimpleMembershipProvider keeps database connections open on some operations (MySQL Bug #74662, Oracle Bug #20109419) |
||||
|
- Fix for Any Call to RoleExists() returns true whether or not the role exists (MySql bug #75397, Oracle bug #20325391). |
||||
|
- Fix for all dateTimes set as UTC Kind (MySQL Bug #74134, Oracle Bug #20200662). |
||||
|
- Fix for Invalid SQL query when eager loading two nested collections (MySQL Bug #70941, Oracle bug #18049862). |
||||
|
- Fix for chinese characters used in the connection string when connecting to MySql Server (MySQL Bug #70041, Oracle Bug #18141356). |
||||
|
|
||||
|
|
||||
|
|
||||
|
6.9.5 |
||||
|
- Disabled installation on-demand in Installer (Oracle Bug #19670596). |
||||
|
- Fix for Generated SQL requests column that doesn't exist in LINQ to Entities (MySql bug #72004, Oracle bug #19681348). |
||||
|
- Fix for MySQL Connector/NET generates incorrect SQL for LINQ 'StartsWith' queries (MySql bug #72058, Oracle bug #19680236). |
||||
|
- Fix for Exception when using IEnumerable.Contains(model.property) in Where predicate (MySql bug #73643, Oracle bug #19690370). |
||||
|
- Fix for Generated Sql does not contain ORDER BY statement whose is requested by LINQ (MySql bug #73549, Oracle bug #19698010). |
||||
|
- Fix for Web providers registration in machine.config (removed v20 suffix) (MySQL Bug #74080, Oracle Bug #19715398) |
||||
|
- Fix for Error of "Every derived table must have an alias" in LINQ to Entities when using EF6 + DbFirst + View + Take |
||||
|
(MySql Bug #72148, Oracle bug #19356006). |
||||
|
- Fix for 'the method or operation is not implemented' when using linq with orderby (MySQL Bug #70722, Oracle Bug #19681723). |
||||
|
- Fix for Exception "The given key was not present in the dictionary" when using utf16le charset in a query. (MySql #72737, Oracle Bug #19355906) |
||||
|
- Fix for Memory leak in a loop opening a connection to the database and executing a command (MySql Bug #73122, Oracle Bug #19467233). |
||||
|
- Fix for Multiple issues caused by trailing and leading white space character in params using MySql Membership Provider (MySql Bug #73411, Oracle Bug #19453313) |
||||
|
- Fix for bad assumption leads to modify query adding CALL statement to the beginning of the sql query even when CommandType.Text is specified (MySql Bug #72736, Oracle Bug #19325120). |
||||
|
|
||||
|
|
||||
|
6.9.4 |
||||
|
- Added a new plugin for MySql Fabric 1.5 support |
||||
|
|
||||
|
|
||||
|
6.9.3 |
||||
|
- Fix for Web Parts Personalization provider |
||||
|
- Fix for changing the PK between two int columns (MySql Bug #71418, Oracle bug #18923294). |
||||
|
- Fix for Error when Calling MySqlConnection.GetSchema("PROCEDURES WITH PARAMETERS", ...) (Oracle bug #19285959). |
||||
|
- Fix for EF provider reports ManifestProviderToken = 5.6 for server 5.7 (Oracle bug #19453814). |
||||
|
- Fix for Fluent API DbModelBuilder.HasColumnType is ignored in EF6 (Oracle bug #19456229). |
||||
|
- Fix for Setting a PK GUID identity in Code First in EF6 no longer works in Server 5.7 (Oracle bug #19456452). |
||||
|
- Non PKs declared as Identity GUID have no GUID autogenerated (Oracle bug #19456415). |
||||
|
|
||||
|
|
||||
|
6.9.2 |
||||
|
- Add async/await compatible methods |
||||
|
- Fix for Unable to read geometry column when it has been set with a SRID value. (MySql Bug #71869, Oracle Bug #19137999) |
||||
|
- Fix for Exception adding a new column to an existing model as identity and PK fails when applying the migration (MySql Bug #71418, Oracle bug #18923294). |
||||
|
- Added SiteMap and Personalization configuration web providers to MySql.Web Nuget Package. |
||||
|
|
||||
|
|
||||
|
6.9.1 |
||||
|
- Fix for Exception of "duplicate entry" in MySqlSessionProvider (MySql Bug #70409, Oracle bug #18657550). |
||||
|
|
||||
|
|
||||
|
6.9.0 |
||||
|
- Added implementation of MySQLPersonalizationProvider. |
||||
|
- Added SiteMap Web provider. |
||||
|
- Added Simple Membership Web Provider. |
||||
|
- Fix for open sockets connections left when connection open fails, the error happens when the client try to get a connection when the max number of connections is reached in the server. (MySql #72025, Oracle Bug #18665388). |
||||
@ -0,0 +1,15 @@ |
|||||
|
Connector/Net 6.9 Release Notes |
||||
|
------------------------------------ |
||||
|
|
||||
|
Welcome to the release notes for Connector/Net 6.9 |
||||
|
|
||||
|
What's new in 6.9 |
||||
|
-------------------- |
||||
|
|
||||
|
- Simple Membership Web Provider |
||||
|
- Site Map Web Provider |
||||
|
- Personalization Web Provider |
||||
|
- MySql Fabric support |
||||
|
|
||||
|
|
||||
|
Be sure and check the documentation for more information on these new features. |
||||
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<configuration> |
||||
|
<system.data> |
||||
|
<DbProviderFactories> |
||||
|
<remove invariant="MySql.Data.MySqlClient" /> |
||||
|
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.10.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> |
||||
|
</DbProviderFactories> |
||||
|
</system.data> |
||||
|
</configuration> |
||||
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<configuration> |
||||
|
<system.data> |
||||
|
<DbProviderFactories> |
||||
|
<remove invariant="MySql.Data.MySqlClient" /> |
||||
|
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.10.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> |
||||
|
</DbProviderFactories> |
||||
|
</system.data> |
||||
|
</configuration> |
||||
@ -1,32 +0,0 @@ |
|||||
|
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|
||||
# Visual Studio 14 |
|
||||
VisualStudioVersion = 14.0.25420.1 |
|
||||
MinimumVisualStudioVersion = 10.0.40219.1 |
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagConfig", "TagConfig\TagConfig.csproj", "{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}" |
|
||||
EndProject |
|
||||
Global |
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|
||||
Debug|Any CPU = Debug|Any CPU |
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms |
|
||||
Debug|x86 = Debug|x86 |
|
||||
Release|Any CPU = Release|Any CPU |
|
||||
Release|Mixed Platforms = Release|Mixed Platforms |
|
||||
Release|x86 = Release|x86 |
|
||||
EndGlobalSection |
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|
||||
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|Any CPU.ActiveCfg = Debug|x86 |
|
||||
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 |
|
||||
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|Mixed Platforms.Build.0 = Debug|x86 |
|
||||
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|x86.ActiveCfg = Debug|x86 |
|
||||
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Debug|x86.Build.0 = Debug|x86 |
|
||||
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|Any CPU.ActiveCfg = Release|x86 |
|
||||
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|Mixed Platforms.ActiveCfg = Release|x86 |
|
||||
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|Mixed Platforms.Build.0 = Release|x86 |
|
||||
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|x86.ActiveCfg = Release|x86 |
|
||||
{18F86945-9CB9-4149-A09C-85B8C5C7C4ED}.Release|x86.Build.0 = Release|x86 |
|
||||
EndGlobalSection |
|
||||
GlobalSection(SolutionProperties) = preSolution |
|
||||
HideSolutionNode = FALSE |
|
||||
EndGlobalSection |
|
||||
EndGlobal |
|
||||
@ -1,739 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Data; |
|
||||
using System.Data.SqlClient; |
|
||||
using System.IO; |
|
||||
using System.Text; |
|
||||
using System.Text.RegularExpressions; |
|
||||
|
|
||||
namespace TagConfig |
|
||||
{ |
|
||||
public static class DataHelper //:MarshalByRefObject
|
|
||||
{ |
|
||||
public static string m_ConnStr = null; |
|
||||
|
|
||||
public static void CallException(string message) |
|
||||
{ |
|
||||
Program.AddErrorLog(new Exception(message)); |
|
||||
} |
|
||||
|
|
||||
public static DataTable ConvertTextToTable(string str) |
|
||||
{ |
|
||||
if (string.IsNullOrEmpty(str)) return null; |
|
||||
DataTable mydt = new DataTable(""); |
|
||||
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(str))) |
|
||||
{ |
|
||||
using (var mysr = new StreamReader(stream)) |
|
||||
{ |
|
||||
string strline = mysr.ReadLine(); |
|
||||
string[] aryline = strline.Split('\t'); |
|
||||
for (int i = 0; i < aryline.Length; i++) |
|
||||
{ |
|
||||
aryline[i] = aryline[i].Replace("\"", ""); |
|
||||
mydt.Columns.Add(new DataColumn(aryline[i] + i)); |
|
||||
} |
|
||||
int intColCount = aryline.Length; |
|
||||
while ((strline = mysr.ReadLine()) != null) |
|
||||
{ |
|
||||
aryline = strline.Split('\t'); |
|
||||
DataRow mydr = mydt.NewRow(); |
|
||||
for (int i = 0; i < intColCount; i++) |
|
||||
{ |
|
||||
mydr[i] = aryline[i].Replace("\"", ""); |
|
||||
} |
|
||||
mydt.Rows.Add(mydr); |
|
||||
} |
|
||||
return mydt; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public static DataTable ConvertCSVToTable(string str) |
|
||||
{ |
|
||||
DataTable mydt = new DataTable(""); |
|
||||
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(str))) |
|
||||
{ |
|
||||
using (var mysr = new StreamReader(stream)) |
|
||||
{ |
|
||||
string strline = mysr.ReadLine(); |
|
||||
|
|
||||
Regex reg = new Regex(@",(?=(?:[^\""]*\""[^\""]*\"")*(?![^\""]*\""))"); |
|
||||
string[] aryline = reg.Split(strline); |
|
||||
for (int i = 0; i < aryline.Length; i++) |
|
||||
{ |
|
||||
aryline[i] = aryline[i].Replace("\"", ""); |
|
||||
mydt.Columns.Add(new DataColumn(aryline[i])); |
|
||||
} |
|
||||
int intColCount = aryline.Length; |
|
||||
while ((strline = mysr.ReadLine()) != null) |
|
||||
{ |
|
||||
aryline = reg.Split(strline); |
|
||||
|
|
||||
DataRow mydr = mydt.NewRow(); |
|
||||
for (int i = 0; i < intColCount; i++) |
|
||||
{ |
|
||||
mydr[i] = aryline[i].Replace("\"", ""); |
|
||||
} |
|
||||
mydt.Rows.Add(mydr); |
|
||||
} |
|
||||
return mydt; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public static bool ConnectionTest() |
|
||||
{ |
|
||||
//创建连接对象
|
|
||||
SqlConnection m_Conn = new SqlConnection(m_ConnStr); |
|
||||
//mySqlConnection.ConnectionTimeout = 1;//设置连接超时的时间
|
|
||||
try |
|
||||
{ |
|
||||
//Open DataBase
|
|
||||
//打开数据库
|
|
||||
m_Conn.Open(); |
|
||||
if (m_Conn.State == ConnectionState.Open) |
|
||||
{ |
|
||||
m_Conn.Close(); |
|
||||
return true; |
|
||||
} |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
CallException(e.Message); |
|
||||
} |
|
||||
//mySqlConnection is a SqlConnection object
|
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
public static SqlParameter CreateInputParam(string paramName, SqlDbType dbType, object objValue) |
|
||||
{ |
|
||||
SqlParameter parameter = new SqlParameter(paramName, dbType); |
|
||||
if (objValue == null) |
|
||||
{ |
|
||||
parameter.IsNullable = true; |
|
||||
parameter.Value = DBNull.Value; |
|
||||
return parameter; |
|
||||
} |
|
||||
parameter.Value = objValue; |
|
||||
return parameter; |
|
||||
} |
|
||||
|
|
||||
#region ExecuteDataset //执行查询语句,返回一个记录集
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 返回记录集
|
|
||||
/// </summary>
|
|
||||
/// <param name="SQL">用于返回记录集的SQL语句</param>
|
|
||||
/// <returns>记录集</returns>
|
|
||||
public static DataSet ExecuteDataset(string SQL) |
|
||||
{ |
|
||||
DataSet ds = new DataSet(); |
|
||||
try |
|
||||
{ |
|
||||
SqlConnection m_Conn; |
|
||||
m_Conn = new SqlConnection(m_ConnStr); |
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
SqlCommand cmd = new SqlCommand(SQL, m_Conn); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(ds); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
CallException(e.Message); |
|
||||
} |
|
||||
return ds; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 返回记录集
|
|
||||
/// </summary>
|
|
||||
/// <param name="SQL">用于返回记录集的SQL语句</param>
|
|
||||
/// <param name="TableName">映射表名</param>
|
|
||||
/// <returns>记录集</returns>
|
|
||||
public static DataSet ExecuteDataset(string SQL, string TableName) |
|
||||
{ |
|
||||
DataSet ds = new DataSet(); |
|
||||
try |
|
||||
{ |
|
||||
SqlConnection m_Conn; |
|
||||
m_Conn = new SqlConnection(m_ConnStr); |
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
SqlCommand cmd = new SqlCommand(SQL, m_Conn); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(ds, TableName); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
CallException(e.Message); |
|
||||
} |
|
||||
return ds; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 返回包含多个表的记录集
|
|
||||
/// </summary>
|
|
||||
/// <param name="SQLs">用于返回记录集的SQL语句</param>
|
|
||||
/// <param name="TableNames">映射表名</param>
|
|
||||
/// <returns>记录集</returns>
|
|
||||
|
|
||||
public static DataSet ExecuteDataset(string[] SQLs, string[] TableNames) |
|
||||
{ |
|
||||
DataSet ds = new DataSet(); |
|
||||
try |
|
||||
{ |
|
||||
SqlConnection m_Conn; |
|
||||
m_Conn = new SqlConnection(m_ConnStr); |
|
||||
for (int i = 0; i < SQLs.Length; i++) |
|
||||
{ |
|
||||
|
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
SqlCommand cmd = new SqlCommand(SQLs[i], m_Conn); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(ds, TableNames[i]); |
|
||||
} |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
CallException(e.Message); |
|
||||
} |
|
||||
return ds; |
|
||||
} |
|
||||
|
|
||||
#endregion ExecuteDataset
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 返回表
|
|
||||
/// </summary>
|
|
||||
/// <param name="SQL">用于返回记录集的SQL语句</param>
|
|
||||
/// <returns>记录集</returns>
|
|
||||
public static DataTable ExecuteDataTable(string SQL) |
|
||||
{ |
|
||||
DataTable dt = new DataTable(); |
|
||||
try |
|
||||
{ |
|
||||
SqlConnection m_Conn; |
|
||||
m_Conn = new SqlConnection(m_ConnStr); |
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
SqlCommand cmd = new SqlCommand(SQL, m_Conn); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(dt); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
CallException(e.Message); |
|
||||
} |
|
||||
return dt; |
|
||||
} |
|
||||
|
|
||||
#region ExecuteNonQuery //执行非查询语句
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行一条INSERT、UPDATE、DELETE语句
|
|
||||
/// </summary>
|
|
||||
/// <param name="SQL">T-SQL语句</param>
|
|
||||
/// <returns>返回影响的行数</returns>
|
|
||||
public static int ExecuteNonQuery(string SQL) |
|
||||
{ |
|
||||
int res = -1; |
|
||||
SqlConnection m_Conn; |
|
||||
m_Conn = new SqlConnection(m_ConnStr); |
|
||||
SqlTransaction sqlT = null; |
|
||||
try |
|
||||
{ |
|
||||
SqlCommand cmd = new SqlCommand(SQL, m_Conn); |
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
cmd.Connection = m_Conn; |
|
||||
sqlT = m_Conn.BeginTransaction(); |
|
||||
cmd.Transaction = sqlT; |
|
||||
res = cmd.ExecuteNonQuery(); |
|
||||
sqlT.Commit(); |
|
||||
m_Conn.Close(); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
if (sqlT != null) |
|
||||
sqlT.Rollback(); |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
return -1; |
|
||||
} |
|
||||
return res; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行一组INSERT、UPDATE、DELETE语句
|
|
||||
/// </summary>
|
|
||||
/// <param name="SQLs">T-SQL语句</param>
|
|
||||
/// <returns>返回影响的行数</returns>
|
|
||||
public static int ExecuteNonQuery(string[] SQLs) |
|
||||
{ |
|
||||
int res = -1; |
|
||||
SqlConnection m_Conn; |
|
||||
m_Conn = new SqlConnection(m_ConnStr); |
|
||||
SqlTransaction sqlT = null; |
|
||||
SqlCommand cmd = new SqlCommand(); |
|
||||
try |
|
||||
{ |
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
cmd.Connection = m_Conn; |
|
||||
sqlT = m_Conn.BeginTransaction(); |
|
||||
cmd.Transaction = sqlT; |
|
||||
for (int i = 0; i < SQLs.Length; i++) |
|
||||
{ |
|
||||
cmd.CommandText = SQLs[i]; |
|
||||
res = cmd.ExecuteNonQuery(); |
|
||||
} |
|
||||
sqlT.Commit(); |
|
||||
m_Conn.Close(); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
if (sqlT != null) |
|
||||
sqlT.Rollback(); |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
res = -1; |
|
||||
} |
|
||||
return res; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行一组INSERT、UPDATE、DELETE语句
|
|
||||
/// </summary>
|
|
||||
/// <param name="SQLs">T-SQL语句</param>
|
|
||||
/// <param name="Pars">执行参数</param>
|
|
||||
/// <returns>返回影响的行数</returns>
|
|
||||
public static int ExecuteNonQuery(string[] SQLs, object[][] Pars) |
|
||||
{ |
|
||||
int res = -1; |
|
||||
SqlConnection m_Conn; |
|
||||
m_Conn = new SqlConnection(m_ConnStr); |
|
||||
SqlTransaction sqlT = null; |
|
||||
SqlCommand cmd = new SqlCommand(); |
|
||||
try |
|
||||
{ |
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
cmd.Connection = m_Conn; |
|
||||
sqlT = m_Conn.BeginTransaction(); |
|
||||
cmd.Transaction = sqlT; |
|
||||
for (int i = 0; i < SQLs.Length; i++) |
|
||||
{ |
|
||||
cmd.CommandText = SQLs[i]; |
|
||||
cmd.Parameters.Clear(); |
|
||||
for (int j = 0; j < Pars[i].Length; j++) |
|
||||
{ |
|
||||
cmd.Parameters.AddWithValue("@p" + j.ToString(), Pars[i][j]); |
|
||||
} |
|
||||
res = cmd.ExecuteNonQuery(); |
|
||||
} |
|
||||
sqlT.Commit(); |
|
||||
m_Conn.Close(); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
if (sqlT != null) |
|
||||
sqlT.Rollback(); |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
res = -1; |
|
||||
} |
|
||||
return res; |
|
||||
} |
|
||||
|
|
||||
#endregion ExecuteNonQuery
|
|
||||
|
|
||||
#region FillDataSet //填充一个记录集
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 用指定的SQL语句来填充一个记录集
|
|
||||
/// </summary>
|
|
||||
/// <param name="ds">记录集</param>
|
|
||||
/// <param name="SQL">SELECT语句</param>
|
|
||||
/// <param name="TableName">映射表名</param>
|
|
||||
public static void FillDataSet(ref DataSet ds, string SQL, string TableName) |
|
||||
{ |
|
||||
try |
|
||||
{ |
|
||||
SqlConnection m_Conn; |
|
||||
m_Conn = new SqlConnection(m_ConnStr); |
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
SqlCommand cmd = new SqlCommand(SQL, m_Conn); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(ds, TableName); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
CallException(e.Message); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
#endregion FillDataSet
|
|
||||
|
|
||||
#region
|
|
||||
// <summary>
|
|
||||
/// 返回一个SqlDataReader
|
|
||||
/// </summary>
|
|
||||
public static SqlDataReader ExecuteReader(string sSQL) |
|
||||
{ |
|
||||
SqlConnection connection = new SqlConnection(m_ConnStr); |
|
||||
SqlCommand command = new SqlCommand(sSQL, connection); |
|
||||
if (connection.State == ConnectionState.Closed) |
|
||||
connection.Open(); |
|
||||
return command.ExecuteReader(CommandBehavior.CloseConnection); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
public static SqlDataReader ExecuteProcedureReader(string sSQL, params SqlParameter[] ParaName) |
|
||||
{ |
|
||||
SqlConnection connection = new SqlConnection(m_ConnStr); |
|
||||
SqlCommand command = new SqlCommand(sSQL, connection); |
|
||||
command.CommandType = CommandType.StoredProcedure; |
|
||||
if (ParaName != null) |
|
||||
{ |
|
||||
command.Parameters.AddRange(ParaName); |
|
||||
} |
|
||||
try |
|
||||
{ |
|
||||
if (connection.State == ConnectionState.Closed) |
|
||||
connection.Open(); |
|
||||
return command.ExecuteReader(CommandBehavior.CloseConnection); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
CallException(e.Message); |
|
||||
return null; |
|
||||
} |
|
||||
} |
|
||||
#endregion
|
|
||||
|
|
||||
#region ExecuteScalar //执行查询,并返回查询所返回的结果集中第一行的第一列
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行查询,并返回查询所返回的结果集中第一行的第一列
|
|
||||
/// </summary>
|
|
||||
/// <param name="sSQL">SQL语句</param>
|
|
||||
/// <returns></returns>
|
|
||||
public static object ExecuteScalar(string sSQL) |
|
||||
{ |
|
||||
object res = null; |
|
||||
SqlTransaction sqlT = null; |
|
||||
SqlConnection m_Conn = new SqlConnection(m_ConnStr); |
|
||||
SqlCommand cmd = new SqlCommand(sSQL, m_Conn); |
|
||||
try |
|
||||
{ |
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
sqlT = m_Conn.BeginTransaction(); |
|
||||
cmd.Transaction = sqlT; |
|
||||
res = cmd.ExecuteScalar(); |
|
||||
sqlT.Commit(); |
|
||||
m_Conn.Close(); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
if (sqlT != null) |
|
||||
sqlT.Rollback(); |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
res = null; |
|
||||
} |
|
||||
return res; |
|
||||
} |
|
||||
|
|
||||
#endregion ExecuteScalar
|
|
||||
|
|
||||
#region ExecuteStoredProcedure //执行一个存储过程
|
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行一个带参数的存储过程
|
|
||||
/// </summary>
|
|
||||
/// <param name="ProName">存储过程名</param>
|
|
||||
/// <param name="ParaName">参数名称</param>
|
|
||||
/// <param name="ParaDir">参数方向,Input参数是输入参数 InputOutput参数既能输入,也能输出 Output参数是输出参数 ReturnValue参数存储过程返回值。</param>
|
|
||||
/// <param name="Para">参数对象数组</param>
|
|
||||
/// <returns>成功返回true,失败返回false</returns>
|
|
||||
public static int ExecuteStoredProcedure(string ProName, params SqlParameter[] ParaName) |
|
||||
{ |
|
||||
SqlConnection m_Conn = new SqlConnection(m_ConnStr); |
|
||||
try |
|
||||
{ |
|
||||
SqlCommand cmd = new SqlCommand(ProName, m_Conn) |
|
||||
{ |
|
||||
CommandType = CommandType.StoredProcedure |
|
||||
}; |
|
||||
if (ParaName != null) |
|
||||
{ |
|
||||
cmd.Parameters.AddRange(ParaName); |
|
||||
} |
|
||||
SqlParameter param = new SqlParameter(); |
|
||||
cmd.Parameters.Add(param); |
|
||||
param.Direction = ParameterDirection.ReturnValue; |
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
{ |
|
||||
m_Conn.Open(); |
|
||||
} |
|
||||
cmd.ExecuteNonQuery(); |
|
||||
m_Conn.Close(); |
|
||||
return (int)param.Value; |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
return -1; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行一个没有参数和返回值的存储过程(默认参数类型)
|
|
||||
/// </summary>
|
|
||||
/// <param name="ProName">存储过程名</param>
|
|
||||
/// <param name="Para">参数对象数组</param>
|
|
||||
/// <returns>成功返回true,失败返回false</returns>
|
|
||||
public static bool ExecuteStoredProcedure(string ProName) |
|
||||
{ |
|
||||
SqlConnection m_Conn; |
|
||||
m_Conn = new SqlConnection(m_ConnStr); |
|
||||
try |
|
||||
{ |
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
SqlCommand cmd = new SqlCommand(ProName, m_Conn); |
|
||||
cmd.CommandType = CommandType.StoredProcedure; |
|
||||
cmd.ExecuteNonQuery(); |
|
||||
m_Conn.Close(); |
|
||||
return true; |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
return false; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行一个带参数的存储过程,并返回数据集
|
|
||||
/// </summary>
|
|
||||
/// <param name="ProName">存储过程名</param>
|
|
||||
/// <param name="ParaName">参数名称</param>
|
|
||||
/// <param name="Para">参数对象数组</param>
|
|
||||
/// <param name="ds">执行过程中返回的数据集</param>
|
|
||||
/// <returns>成功返回true,失败返回false</returns>
|
|
||||
public static DataSet ExecuteDataSetProcedure(string ProName, ref int returnValue, params SqlParameter[] ParaName) |
|
||||
{ |
|
||||
SqlConnection m_Conn = new SqlConnection(m_ConnStr); ; |
|
||||
DataSet ds = new DataSet(); |
|
||||
try |
|
||||
{ |
|
||||
SqlCommand cmd = new SqlCommand(ProName, m_Conn); |
|
||||
cmd.CommandType = CommandType.StoredProcedure; |
|
||||
if (ParaName != null) |
|
||||
{ |
|
||||
cmd.Parameters.AddRange(ParaName); |
|
||||
} |
|
||||
SqlParameter param = new SqlParameter { Direction = ParameterDirection.ReturnValue }; |
|
||||
cmd.Parameters.Add(param); |
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(ds); |
|
||||
m_Conn.Close(); |
|
||||
returnValue = (int)param.Value; |
|
||||
return ds; |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
return null; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public static DataSet ExecuteDataSetProcedure(string ProName, params SqlParameter[] ParaName) |
|
||||
{ |
|
||||
SqlConnection m_Conn = new SqlConnection(m_ConnStr); ; |
|
||||
DataSet ds = new DataSet(); |
|
||||
try |
|
||||
{ |
|
||||
SqlCommand cmd = new SqlCommand(ProName, m_Conn); |
|
||||
cmd.CommandType = CommandType.StoredProcedure; |
|
||||
if (ParaName != null) |
|
||||
{ |
|
||||
cmd.Parameters.AddRange(ParaName); |
|
||||
} |
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(ds); |
|
||||
m_Conn.Close(); |
|
||||
return ds; |
|
||||
} |
|
||||
|
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
return null; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行一个带参数的存储过程,并返回数据集
|
|
||||
/// </summary>
|
|
||||
/// <param name="ProName">存储过程名</param>
|
|
||||
/// <param name="ParaName">参数名称</param>
|
|
||||
/// <param name="Para">参数对象数组</param>
|
|
||||
/// <param name="ds">执行过程中返回的数据集</param>
|
|
||||
/// <returns>成功返回true,失败返回false</returns>
|
|
||||
///
|
|
||||
public static DataTable ExecuteDataTableProcedure(string ProName, params SqlParameter[] ParaName) |
|
||||
{ |
|
||||
SqlConnection m_Conn = new SqlConnection(m_ConnStr); |
|
||||
DataTable ds = new DataTable(); |
|
||||
try |
|
||||
{ |
|
||||
SqlCommand cmd = new SqlCommand(ProName, m_Conn); |
|
||||
cmd.CommandType = CommandType.StoredProcedure; |
|
||||
if (ParaName != null) |
|
||||
{ |
|
||||
cmd.Parameters.AddRange(ParaName); |
|
||||
} |
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(ds); |
|
||||
m_Conn.Close(); |
|
||||
return ds; |
|
||||
} |
|
||||
|
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
return null; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public static DataTable ExecuteDataTableProcedure(string ProName, ref int returnValue, SqlParameter[] ParaName) |
|
||||
{ |
|
||||
SqlConnection m_Conn = new SqlConnection(m_ConnStr); |
|
||||
DataTable ds = new DataTable(); |
|
||||
try |
|
||||
{ |
|
||||
SqlCommand cmd = new SqlCommand(ProName, m_Conn); |
|
||||
cmd.CommandType = CommandType.StoredProcedure; |
|
||||
if (ParaName != null) |
|
||||
{ |
|
||||
cmd.Parameters.AddRange(ParaName); |
|
||||
} |
|
||||
SqlParameter param = new SqlParameter { Direction = ParameterDirection.ReturnValue }; |
|
||||
cmd.Parameters.Add(param); |
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(ds); |
|
||||
m_Conn.Close(); |
|
||||
returnValue = (int)param.Value; |
|
||||
return ds; |
|
||||
} |
|
||||
|
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
return null; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行一个带参数的存储过程,同时输出一行
|
|
||||
/// </summary>
|
|
||||
/// <param name="ProName">存储过程名</param>
|
|
||||
/// <param name="ParaName">参数名称</param>
|
|
||||
/// <param name="Para">参数对象数组</param>
|
|
||||
/// <returns>返回整数</returns>
|
|
||||
public static DataRow ExecuteDataRowProcedure(string ProName, params SqlParameter[] ParaName) |
|
||||
{ |
|
||||
SqlConnection m_Conn = new SqlConnection(m_ConnStr); |
|
||||
|
|
||||
try |
|
||||
{ |
|
||||
SqlCommand cmd = new SqlCommand(ProName, m_Conn); |
|
||||
cmd.CommandType = CommandType.StoredProcedure; |
|
||||
if (ParaName != null) |
|
||||
{ |
|
||||
cmd.Parameters.AddRange(ParaName); |
|
||||
} |
|
||||
|
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
DataTable table = new DataTable(); |
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(table); |
|
||||
m_Conn.Close(); |
|
||||
if (table.Rows.Count > 0) |
|
||||
return table.Rows[0]; |
|
||||
else |
|
||||
return table.NewRow(); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
return null; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行一个带参数的存储过程,同时输出一行
|
|
||||
/// </summary>
|
|
||||
/// <param name="ProName">存储过程名</param>
|
|
||||
/// <param name="ParaName">参数名称</param>
|
|
||||
/// <param name="Para">参数对象数组</param>
|
|
||||
/// <returns>返回整数</returns>
|
|
||||
public static DataRowView ExecuteDataRowViewProcedure(string ProName, params SqlParameter[] ParaName) |
|
||||
{ |
|
||||
SqlConnection m_Conn = new SqlConnection(m_ConnStr); |
|
||||
|
|
||||
try |
|
||||
{ |
|
||||
SqlCommand cmd = new SqlCommand(ProName, m_Conn); |
|
||||
cmd.CommandType = CommandType.StoredProcedure; |
|
||||
if (ParaName != null) |
|
||||
{ |
|
||||
cmd.Parameters.AddRange(ParaName); |
|
||||
} |
|
||||
|
|
||||
if (m_Conn.State == ConnectionState.Closed) |
|
||||
m_Conn.Open(); |
|
||||
DataTable table = new DataTable(); |
|
||||
SqlDataAdapter da = new SqlDataAdapter(); |
|
||||
da.SelectCommand = cmd; |
|
||||
da.Fill(table); |
|
||||
m_Conn.Close(); |
|
||||
if (table.Rows.Count > 0) |
|
||||
return table.DefaultView[0]; |
|
||||
else |
|
||||
return table.DefaultView.AddNew(); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
m_Conn.Close(); |
|
||||
CallException(e.Message); |
|
||||
return null; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
#endregion ExecuteStoredProcedure
|
|
||||
} |
|
||||
} |
|
||||
@ -1,6 +0,0 @@ |
|||||
<?xml version="1.0"?> |
|
||||
<configuration> |
|
||||
<configSections> |
|
||||
</configSections> |
|
||||
<connectionStrings/> |
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration> |
|
||||
@ -1,6 +0,0 @@ |
|||||
<?xml version="1.0"?> |
|
||||
<configuration> |
|
||||
<configSections> |
|
||||
</configSections> |
|
||||
<connectionStrings/> |
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration> |
|
||||
@ -1,11 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> |
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> |
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> |
|
||||
<security> |
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> |
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/> |
|
||||
</requestedPrivileges> |
|
||||
</security> |
|
||||
</trustInfo> |
|
||||
</assembly> |
|
||||
@ -1,6 +0,0 @@ |
|||||
<?xml version="1.0"?> |
|
||||
<configuration> |
|
||||
<configSections> |
|
||||
</configSections> |
|
||||
<connectionStrings/> |
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration> |
|
||||
@ -1,6 +0,0 @@ |
|||||
<?xml version="1.0"?> |
|
||||
<configuration> |
|
||||
<configSections> |
|
||||
</configSections> |
|
||||
<connectionStrings/> |
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration> |
|
||||
@ -1,11 +0,0 @@ |
|||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> |
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> |
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> |
|
||||
<security> |
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> |
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/> |
|
||||
</requestedPrivileges> |
|
||||
</security> |
|
||||
</trustInfo> |
|
||||
</assembly> |
|
||||
@ -1 +0,0 @@ |
|||||
C:\Users\Yinan\Documents\Github\SharpSCADA\SCADA\TagConfig\TagConfig\bin\Debug\TagConfig.exe.config |
|
||||