From 75945aac6566d8501ca9ff07dcc335f3cca3f54c Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sat, 1 Jul 2017 12:04:00 +0200 Subject: [PATCH] add an ado .net example --- .gitattributes | 63 +++++++++++++++++++ software/1_sem/adonet/ConsoleApp1.sln | 22 +++++++ software/1_sem/adonet/ConsoleApp1/App.config | 6 ++ .../adonet/ConsoleApp1/ConsoleApp1.csproj | 52 +++++++++++++++ software/1_sem/adonet/ConsoleApp1/Program.cs | 41 ++++++++++++ .../ConsoleApp1/Properties/AssemblyInfo.cs | 36 +++++++++++ 6 files changed, 220 insertions(+) create mode 100644 .gitattributes create mode 100644 software/1_sem/adonet/ConsoleApp1.sln create mode 100644 software/1_sem/adonet/ConsoleApp1/App.config create mode 100644 software/1_sem/adonet/ConsoleApp1/ConsoleApp1.csproj create mode 100644 software/1_sem/adonet/ConsoleApp1/Program.cs create mode 100644 software/1_sem/adonet/ConsoleApp1/Properties/AssemblyInfo.cs diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/software/1_sem/adonet/ConsoleApp1.sln b/software/1_sem/adonet/ConsoleApp1.sln new file mode 100644 index 0000000..e3d7fb3 --- /dev/null +++ b/software/1_sem/adonet/ConsoleApp1.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{19A15CAF-642C-49CD-A808-CF5460A5ABEC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {19A15CAF-642C-49CD-A808-CF5460A5ABEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19A15CAF-642C-49CD-A808-CF5460A5ABEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19A15CAF-642C-49CD-A808-CF5460A5ABEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19A15CAF-642C-49CD-A808-CF5460A5ABEC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/software/1_sem/adonet/ConsoleApp1/App.config b/software/1_sem/adonet/ConsoleApp1/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/software/1_sem/adonet/ConsoleApp1/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/software/1_sem/adonet/ConsoleApp1/ConsoleApp1.csproj b/software/1_sem/adonet/ConsoleApp1/ConsoleApp1.csproj new file mode 100644 index 0000000..ad2c06a --- /dev/null +++ b/software/1_sem/adonet/ConsoleApp1/ConsoleApp1.csproj @@ -0,0 +1,52 @@ + + + + + Debug + AnyCPU + {19A15CAF-642C-49CD-A808-CF5460A5ABEC} + Exe + ConsoleApp1 + ConsoleApp1 + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/software/1_sem/adonet/ConsoleApp1/Program.cs b/software/1_sem/adonet/ConsoleApp1/Program.cs new file mode 100644 index 0000000..beac216 --- /dev/null +++ b/software/1_sem/adonet/ConsoleApp1/Program.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + SqlConnection con = new SqlConnection(@"Data Source=(local)\SQLEXPRESS; + Initial Catalog=Abo; + Integrated Security=True"); + Console.WriteLine(con); + try + { + con.Open(); + //string sql = "insert into ort (postleizahl,ortsname) values (5000, 'Aarau')"; + //SqlCommand cmd = new SqlCommand(sql, con); + //cmd.ExecuteNonQuery(); + + string sql = "select postleizahl, ortsname from ort order by postleizahl"; + SqlCommand cmd = new SqlCommand(sql, con); + SqlDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + Console.WriteLine(dr["postleizahl"] + "\t" + dr["ortsname"]); + } + Console.ReadKey(); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + } +} diff --git a/software/1_sem/adonet/ConsoleApp1/Properties/AssemblyInfo.cs b/software/1_sem/adonet/ConsoleApp1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..da9f341 --- /dev/null +++ b/software/1_sem/adonet/ConsoleApp1/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ConsoleApp1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ConsoleApp1")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("19a15caf-642c-49cd-a808-cf5460a5abec")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]