Skip to content

Commit b1b2a02

Browse files
authored
SFI ROPC: Remove problematic connection strings (#11237)
1 parent 75d0922 commit b1b2a02

File tree

17 files changed

+167
-331
lines changed

17 files changed

+167
-331
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"ConnectionStrings": {
3-
"DataGrid_CellSelection.Properties.Settings.AdventureWorksLT2008ConnectionString": "Data Source=jgalasyn1;Initial Catalog=AdventureWorksLT2008;Integrated Security=True"
3+
"DataGrid_CellSelection.Properties.Settings.AdventureWorksLT2008ConnectionString": "Data Source=.;Initial Catalog=AdventureWorksLT2008;Integrated Security=True"
44
}
5-
}
5+
}
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.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="System.Data.Odbc" />
10+
</ItemGroup>
11+
12+
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
using System;
2-
using System.Xml;
3-
using System.Data;
42
using System.Data.Odbc;
5-
using System.Data.Common;
6-
using System.Windows.Forms;
73

8-
public class Form1: Form
4+
public class Example
95
{
10-
protected DataSet DataSet1;
11-
protected DataGrid dataGrid1;
6+
// <Snippet1>
7+
public void CreateOdbcConnection()
8+
{
9+
string connectionString = "...";
1210

13-
// <Snippet1>
14-
public void CreateOdbcConnection()
15-
{
16-
string connectionString = "Driver={SQL Native Client};Server=(local);Trusted_Connection=Yes;Database=AdventureWorks;";
11+
using (OdbcConnection connection = new(connectionString))
12+
{
13+
connection.Open();
14+
Console.WriteLine($"ServerVersion: {connection.ServerVersion}"
15+
+ $"\nDatabase: {connection.Database}");
1716

18-
using (OdbcConnection connection = new OdbcConnection(connectionString))
19-
{
20-
connection.Open();
21-
Console.WriteLine("ServerVersion: " + connection.ServerVersion
22-
+ "\nDatabase: " + connection.Database);
23-
24-
// The connection is automatically closed at
25-
// the end of the Using block.
26-
}
27-
}
28-
// </Snippet1>
17+
// The connection is automatically closed at
18+
// the end of the Using block.
19+
}
20+
}
21+
// </Snippet1>
2922
}
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.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="System.Data.Odbc" />
10+
</ItemGroup>
11+
12+
</Project>

snippets/csharp/VS_Snippets_ADO.NET/Classic WebData OdbcConnection.Database/CS/source.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static void Main(string[] args)
1515
// <Snippet1>
1616
private static void CreateOdbcConnection()
1717
{
18-
string connectionString = "Driver={SQL Native Client};Server=(local);Trusted_Connection=Yes;Database=AdventureWorks;";
18+
string connectionString = "...";
1919

2020
using (OdbcConnection connection = new OdbcConnection(connectionString))
2121
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0-windows</TargetFramework>
6+
<UseWindowsForms>true</UseWindowsForms>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
11+
</ItemGroup>
12+
13+
</Project>

snippets/csharp/VS_Snippets_ADO.NET/Classic WebData SqlDataAdapter.RowUpdated Example/CS/source.cs

+12-18
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
using System;
2-
using System.Xml;
32
using System.Data;
4-
using System.Data.SqlClient;
5-
using System.Data.Common;
63
using System.Windows.Forms;
4+
using Microsoft.Data.SqlClient;
75

8-
public class Form1: Form
6+
public class Form1 : Form
97
{
10-
private DataSet DataSet1;
11-
private DataGrid dataGrid1;
12-
138
// <Snippet1>
149
// handler for RowUpdating event
1510
private static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e)
@@ -25,40 +20,39 @@ private static void OnRowUpdated(object sender, SqlRowUpdatedEventArgs e)
2520

2621
public static int Main()
2722
{
28-
const string connectionString =
29-
"Integrated Security=SSPI;database=Northwind;server=MSSQL1";
23+
const string connectionString = "...";
3024
const string queryString = "SELECT * FROM Products";
3125

3226
// create DataAdapter
33-
SqlDataAdapter adapter = new SqlDataAdapter(queryString, connectionString);
34-
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
27+
SqlDataAdapter adapter = new(queryString, connectionString);
28+
SqlCommandBuilder builder = new(adapter);
3529

3630
// Create and fill DataSet (select only first 5 rows)
37-
DataSet dataSet = new DataSet();
31+
DataSet dataSet = new();
3832
adapter.Fill(dataSet, 0, 5, "Table");
3933

4034
// Modify DataSet
4135
DataTable table = dataSet.Tables["Table"];
4236
table.Rows[0][1] = "new product";
4337

4438
// add handlers
45-
adapter.RowUpdating += new SqlRowUpdatingEventHandler( OnRowUpdating );
46-
adapter.RowUpdated += new SqlRowUpdatedEventHandler( OnRowUpdated );
39+
adapter.RowUpdating += new SqlRowUpdatingEventHandler(OnRowUpdating);
40+
adapter.RowUpdated += new SqlRowUpdatedEventHandler(OnRowUpdated);
4741

4842
// update, this operation fires two events
4943
// (RowUpdating/RowUpdated) per changed row
5044
adapter.Update(dataSet, "Table");
5145

5246
// remove handlers
53-
adapter.RowUpdating -= new SqlRowUpdatingEventHandler( OnRowUpdating );
54-
adapter.RowUpdated -= new SqlRowUpdatedEventHandler( OnRowUpdated );
47+
adapter.RowUpdating -= new SqlRowUpdatingEventHandler(OnRowUpdating);
48+
adapter.RowUpdated -= new SqlRowUpdatedEventHandler(OnRowUpdated);
5549
return 0;
5650
}
5751

5852
private static void PrintEventArgs(SqlRowUpdatingEventArgs args)
5953
{
6054
Console.WriteLine("OnRowUpdating");
61-
Console.WriteLine(" event args: ("+
55+
Console.WriteLine(" event args: (" +
6256
" command=" + args.Command +
6357
" commandType=" + args.StatementType +
6458
" status=" + args.Status + ")");
@@ -67,7 +61,7 @@ private static void PrintEventArgs(SqlRowUpdatingEventArgs args)
6761
private static void PrintEventArgs(SqlRowUpdatedEventArgs args)
6862
{
6963
Console.WriteLine("OnRowUpdated");
70-
Console.WriteLine( " event args: ("+
64+
Console.WriteLine(" event args: (" +
7165
" command=" + args.Command +
7266
" commandType=" + args.StatementType +
7367
" recordsAffected=" + args.RecordsAffected +
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,13 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
33
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>9.0.20612</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{F2593E93-91A2-4F64-88A4-7E3861B3FE01}</ProjectGuid>
9-
<OutputType>WinExe</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>DataViewSamples</RootNamespace>
12-
<AssemblyName>DataViewSamples</AssemblyName>
13-
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
14-
<FileAlignment>512</FileAlignment>
15-
<Nonshipping>true</Nonshipping>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0-windows</TargetFramework>
6+
<UseWindowsForms>true</UseWindowsForms>
167
</PropertyGroup>
17-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18-
<DebugSymbols>true</DebugSymbols>
19-
<DebugType>full</DebugType>
20-
<Optimize>false</Optimize>
21-
<OutputPath>bin\Debug\</OutputPath>
22-
<DefineConstants>DEBUG;TRACE</DefineConstants>
23-
<ErrorReport>prompt</ErrorReport>
24-
<WarningLevel>4</WarningLevel>
25-
</PropertyGroup>
26-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27-
<DebugType>pdbonly</DebugType>
28-
<Optimize>true</Optimize>
29-
<OutputPath>bin\Release\</OutputPath>
30-
<DefineConstants>TRACE</DefineConstants>
31-
<ErrorReport>prompt</ErrorReport>
32-
<WarningLevel>4</WarningLevel>
33-
</PropertyGroup>
34-
<ItemGroup>
35-
<Reference Include="System" />
36-
<Reference Include="System.Core">
37-
<RequiredTargetFramework>3.5</RequiredTargetFramework>
38-
</Reference>
39-
<Reference Include="System.Xml.Linq">
40-
<RequiredTargetFramework>3.5</RequiredTargetFramework>
41-
</Reference>
42-
<Reference Include="System.Data.DataSetExtensions">
43-
<RequiredTargetFramework>3.5</RequiredTargetFramework>
44-
</Reference>
45-
<Reference Include="System.Data" />
46-
<Reference Include="System.Deployment" />
47-
<Reference Include="System.Drawing" />
48-
<Reference Include="System.Windows.Forms" />
49-
<Reference Include="System.Xml" />
50-
</ItemGroup>
8+
519
<ItemGroup>
52-
<Compile Include="Form1.cs">
53-
<SubType>Form</SubType>
54-
</Compile>
55-
<Compile Include="Form1.Designer.cs">
56-
<DependentUpon>Form1.cs</DependentUpon>
57-
</Compile>
58-
<Compile Include="Program.cs" />
59-
<Compile Include="Properties\AssemblyInfo.cs" />
60-
<EmbeddedResource Include="Form1.resx">
61-
<SubType>Designer</SubType>
62-
<DependentUpon>Form1.cs</DependentUpon>
63-
</EmbeddedResource>
64-
<EmbeddedResource Include="Properties\Resources.resx">
65-
<Generator>ResXFileCodeGenerator</Generator>
66-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
67-
<SubType>Designer</SubType>
68-
</EmbeddedResource>
69-
<Compile Include="Properties\Resources.Designer.cs">
70-
<AutoGen>True</AutoGen>
71-
<DependentUpon>Resources.resx</DependentUpon>
72-
</Compile>
73-
<None Include="Properties\Settings.settings">
74-
<Generator>SettingsSingleFileGenerator</Generator>
75-
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
76-
</None>
77-
<Compile Include="Properties\Settings.Designer.cs">
78-
<AutoGen>True</AutoGen>
79-
<DependentUpon>Settings.settings</DependentUpon>
80-
<DesignTimeSharedInput>True</DesignTimeSharedInput>
81-
</Compile>
10+
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
8211
</ItemGroup>
83-
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
84-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
85-
Other similar extension points exist, see Microsoft.Common.targets.
86-
<Target Name="BeforeBuild">
87-
</Target>
88-
<Target Name="AfterBuild">
89-
</Target>
90-
-->
91-
</Project>
12+
13+
</Project>

snippets/csharp/VS_Snippets_ADO.NET/DP DataView Samples/CS/DataViewSamplesCS.csproj

-90
This file was deleted.

0 commit comments

Comments
 (0)