Skip to content

Commit d2e747f

Browse files
committed
add project files
1 parent 5d4ed5a commit d2e747f

File tree

4 files changed

+76
-53
lines changed

4 files changed

+76
-53
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net8</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="System.Data.Odbc" />
10+
</ItemGroup>
11+
12+
</Project>

snippets/csharp/VS_Snippets_ADO.NET/DataWorks OdbcConnectionStringBuilder/CS/source.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
using System;
2-
using System.Data;
32
// <Snippet1>
43
using System.Data.Odbc;
54

65
class Program
76
{
87
static void Main()
98
{
10-
OdbcConnectionStringBuilder builder =
11-
new OdbcConnectionStringBuilder();
12-
builder.Driver = "Microsoft Access Driver (*.mdb)";
9+
OdbcConnectionStringBuilder builder = new()
10+
{
11+
Driver = "Microsoft Access Driver (*.mdb)"
12+
};
1313

1414
// Call the Add method to explicitly add key/value
1515
// pairs to the internal collection.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net8</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="System.Data.Odbc" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,55 @@
1-
Option Explicit
2-
Option Strict
3-
4-
Imports System.Data
1+
Option Explicit On
2+
Option Strict On
53
' <Snippet1>
64
Imports System.Data.Odbc
75

86
Module Module1
9-
Sub Main()
10-
Dim builder As New OdbcConnectionStringBuilder()
11-
builder.Driver = "Microsoft Access Driver (*.mdb)"
12-
13-
' Call the Add method to explicitly add key/value
14-
' pairs to the internal collection.
15-
builder.Add("Dbq", "C:\info.mdb")
16-
17-
Console.WriteLine(builder.ConnectionString)
18-
Console.WriteLine()
19-
20-
' Clear current values and reset known keys to their
21-
' default values.
22-
builder.Clear()
23-
24-
' Pass the OdbcConnectionStringBuilder an existing
25-
' connection string, and you can retrieve and
26-
' modify any of the elements.
27-
builder.ConnectionString = _
28-
"driver={IBM DB2 ODBC DRIVER};Database=SampleDB;" & _
29-
"hostname=SampleServerName;port=SamplePortNum;" & _
30-
"protocol=TCPIP"
31-
32-
Console.WriteLine("protocol = " & builder("protocol").ToString())
33-
Console.WriteLine()
34-
35-
' Call the Remove method to remove items from
36-
' the collection of key/value pairs.
37-
builder.Remove("port")
38-
39-
' Note that calling Remove on a nonexistent item does not
40-
' throw an exception.
41-
builder.Remove("BadItem")
42-
Console.WriteLine(builder.ConnectionString)
43-
Console.WriteLine()
44-
45-
' The Item property is the default for the class,
46-
' and setting the Item property adds the value, if
47-
' necessary.
48-
builder("NewKey") = "newValue"
49-
Console.WriteLine(builder.ConnectionString)
50-
51-
Console.WriteLine("Press Enter to finish.")
52-
Console.ReadLine()
53-
End Sub
7+
Sub Main()
8+
Dim builder As New OdbcConnectionStringBuilder With {
9+
.Driver = "Microsoft Access Driver (*.mdb)"
10+
}
11+
12+
' Call the Add method to explicitly add key/value
13+
' pairs to the internal collection.
14+
builder.Add("Dbq", "C:\info.mdb")
15+
16+
Console.WriteLine(builder.ConnectionString)
17+
Console.WriteLine()
18+
19+
' Clear current values and reset known keys to their
20+
' default values.
21+
builder.Clear()
22+
23+
' Pass the OdbcConnectionStringBuilder an existing
24+
' connection string, and you can retrieve and
25+
' modify any of the elements.
26+
builder.ConnectionString =
27+
"driver={IBM DB2 ODBC DRIVER};Database=SampleDB;" &
28+
"hostname=SampleServerName;port=SamplePortNum;" &
29+
"protocol=TCPIP"
30+
31+
Console.WriteLine("protocol = " & builder("protocol").ToString())
32+
Console.WriteLine()
33+
34+
' Call the Remove method to remove items from
35+
' the collection of key/value pairs.
36+
builder.Remove("port")
37+
38+
' Note that calling Remove on a nonexistent item does not
39+
' throw an exception.
40+
builder.Remove("BadItem")
41+
Console.WriteLine(builder.ConnectionString)
42+
Console.WriteLine()
43+
44+
' The Item property is the default for the class,
45+
' and setting the Item property adds the value, if
46+
' necessary.
47+
builder("NewKey") = "newValue"
48+
Console.WriteLine(builder.ConnectionString)
49+
50+
Console.WriteLine("Press Enter to finish.")
51+
Console.ReadLine()
52+
End Sub
5453
End Module
5554
' </Snippet1>
5655

0 commit comments

Comments
 (0)