Skip to content

Commit 9ba1939

Browse files
committed
fix some build errors
1 parent 78a3ff3 commit 9ba1939

File tree

6 files changed

+46
-235
lines changed

6 files changed

+46
-235
lines changed
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1-
Imports System.Xml
2-
Imports System.Data
1+
Imports System.Data
32
Imports System.Data.SqlClient
4-
Imports System.Data.Common
5-
Imports System.Windows.Forms
63

74

85

9-
Public Class Form1
10-
Inherits Form
11-
Protected DataSet1 As DataSet
12-
Protected dataGrid1 As DataGrid
13-
14-
15-
6+
Public Class Class1
7+
8+
169
' <Snippet1>
1710
Public Sub CreateCommand()
1811
Dim queryString As String = "SELECT * FROM Categories ORDER BY CategoryID"
1912
Dim command As New SqlCommand(queryString)
2013
command.CommandTimeout = 15
2114
command.CommandType = CommandType.Text
22-
End Sub
15+
End Sub
2316
' </Snippet1>
2417
End Class

snippets/visualbasic/System.Data.SqlClient/SqlCommand/BeginExecuteNonQuery/Form1.vb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
Option Explicit On
22
Option Strict On
3-
4-
Imports System.Data
53
' <Snippet1>
64
Imports System.Data.SqlClient
5+
Imports System.Windows.Forms
76

87
Public Class Form1
98
' Add this code to the form's class:
@@ -30,7 +29,7 @@ Public Class Form1
3029
' If you have not included "Asynchronous Processing=true" in the
3130
' connection string, the command is not able
3231
' to execute asynchronously.
33-
Return "Data Source=(local);Integrated Security=true;" & _
32+
Return "Data Source=(local);Integrated Security=true;" &
3433
"Initial Catalog=AdventureWorks; Asynchronous Processing=true"
3534
End Function
3635

@@ -43,21 +42,21 @@ Public Class Form1
4342
DisplayStatus("Ready")
4443
End Sub
4544

46-
Private Sub Form1_FormClosing(ByVal sender As Object, _
47-
ByVal e As System.Windows.Forms.FormClosingEventArgs) _
45+
Private Sub Form1_FormClosing(ByVal sender As Object,
46+
ByVal e As FormClosingEventArgs) _
4847
Handles Me.FormClosing
4948
If isExecuting Then
50-
MessageBox.Show(Me, "Cannot close the form until " & _
49+
MessageBox.Show(Me, "Cannot close the form until " &
5150
"the pending asynchronous command has completed. Please wait...")
5251
e.Cancel = True
5352
End If
5453
End Sub
5554

56-
Private Sub Button1_Click(ByVal sender As System.Object, _
55+
Private Sub Button1_Click(ByVal sender As System.Object,
5756
ByVal e As System.EventArgs) Handles Button1.Click
5857
If isExecuting Then
59-
MessageBox.Show(Me, _
60-
"Already executing. Please wait until the current query " & _
58+
MessageBox.Show(Me,
59+
"Already executing. Please wait until the current query " &
6160
"has completed.")
6261
Else
6362
Dim command As SqlCommand
@@ -69,11 +68,11 @@ Public Class Form1
6968
' a few seconds before working with the data.
7069
' This command does not do much, but that's the point--
7170
' it does not change your data, in the long run.
72-
Dim commandText As String = _
73-
"WAITFOR DELAY '0:0:05';" & _
74-
"UPDATE Production.Product SET ReorderPoint = ReorderPoint + 1 " & _
75-
"WHERE ReorderPoint Is Not Null;" & _
76-
"UPDATE Production.Product SET ReorderPoint = ReorderPoint - 1 " & _
71+
Dim commandText As String =
72+
"WAITFOR DELAY '0:0:05';" &
73+
"UPDATE Production.Product SET ReorderPoint = ReorderPoint + 1 " &
74+
"WHERE ReorderPoint Is Not Null;" &
75+
"UPDATE Production.Product SET ReorderPoint = ReorderPoint - 1 " &
7776
"WHERE ReorderPoint Is Not Null"
7877

7978
command = New SqlCommand(commandText, connection)
@@ -139,7 +138,7 @@ Public Class Form1
139138

140139
' You can create the delegate instance as you
141140
' invoke it, like this:
142-
Me.Invoke(New DisplayInfoDelegate(AddressOf DisplayStatus), _
141+
Me.Invoke(New DisplayInfoDelegate(AddressOf DisplayStatus),
143142
String.Format("Ready(last error: {0}", ex.Message))
144143
Finally
145144
isExecuting = False
Lines changed: 9 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,13 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project 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>8.0.50727</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{C019A781-A425-4338-9553-5D623134FD21}</ProjectGuid>
9-
<OutputType>WinExe</OutputType>
10-
<StartupObject>TesterFormVB.My.MyApplication</StartupObject>
11-
<RootNamespace>TesterFormVB</RootNamespace>
12-
<AssemblyName>TesterFormVB</AssemblyName>
13-
<MyType>WindowsForms</MyType>
14-
<OptionStrict>On</OptionStrict>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net9.0-windows</TargetFramework>
6+
<UseWindowsForms>true</UseWindowsForms>
157
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17-
<DebugSymbols>true</DebugSymbols>
18-
<DebugType>full</DebugType>
19-
<DefineDebug>true</DefineDebug>
20-
<DefineTrace>true</DefineTrace>
21-
<OutputPath>bin\Debug\</OutputPath>
22-
<DocumentationFile>TesterFormVB.xml</DocumentationFile>
23-
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
24-
</PropertyGroup>
25-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26-
<DebugType>pdbonly</DebugType>
27-
<DefineDebug>false</DefineDebug>
28-
<DefineTrace>true</DefineTrace>
29-
<Optimize>true</Optimize>
30-
<OutputPath>bin\Release\</OutputPath>
31-
<DocumentationFile>TesterFormVB.xml</DocumentationFile>
32-
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
33-
</PropertyGroup>
34-
<ItemGroup>
35-
<Reference Include="System" />
36-
<Reference Include="System.Data" />
37-
<Reference Include="System.Deployment" />
38-
<Reference Include="System.Drawing" />
39-
<Reference Include="System.Windows.Forms" />
40-
<Reference Include="System.Xml" />
41-
</ItemGroup>
42-
<ItemGroup>
43-
<Import Include="Microsoft.VisualBasic" />
44-
<Import Include="System" />
45-
<Import Include="System.Collections" />
46-
<Import Include="System.Collections.Generic" />
47-
<Import Include="System.Data" />
48-
<Import Include="System.Drawing" />
49-
<Import Include="System.Diagnostics" />
50-
<Import Include="System.Windows.Forms" />
51-
</ItemGroup>
52-
<ItemGroup>
53-
<Compile Include="Form1.vb">
54-
<SubType>Form</SubType>
55-
</Compile>
56-
<Compile Include="Form1.Designer.vb">
57-
<DependentUpon>Form1.vb</DependentUpon>
58-
<SubType>Form</SubType>
59-
</Compile>
60-
<Compile Include="My Project\AssemblyInfo.vb" />
61-
<Compile Include="My Project\Application.Designer.vb">
62-
<AutoGen>True</AutoGen>
63-
<DependentUpon>Application.myapp</DependentUpon>
64-
</Compile>
65-
<Compile Include="My Project\Resources.Designer.vb">
66-
<AutoGen>True</AutoGen>
67-
<DesignTime>True</DesignTime>
68-
<DependentUpon>Resources.resx</DependentUpon>
69-
</Compile>
70-
<Compile Include="My Project\Settings.Designer.vb">
71-
<AutoGen>True</AutoGen>
72-
<DependentUpon>Settings.settings</DependentUpon>
73-
<DesignTimeSharedInput>True</DesignTimeSharedInput>
74-
</Compile>
75-
</ItemGroup>
76-
<ItemGroup>
77-
<EmbeddedResource Include="My Project\Resources.resx">
78-
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
79-
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
80-
<CustomToolNamespace>My.Resources</CustomToolNamespace>
81-
<SubType>Designer</SubType>
82-
</EmbeddedResource>
83-
</ItemGroup>
8+
849
<ItemGroup>
85-
<None Include="My Project\Application.myapp">
86-
<Generator>MyApplicationCodeGenerator</Generator>
87-
<LastGenOutput>Application.Designer.vb</LastGenOutput>
88-
</None>
89-
<None Include="My Project\Settings.settings">
90-
<Generator>SettingsSingleFileGenerator</Generator>
91-
<CustomToolNamespace>My</CustomToolNamespace>
92-
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
93-
</None>
10+
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
9411
</ItemGroup>
95-
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
96-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
97-
Other similar extension points exist, see Microsoft.Common.targets.
98-
<Target Name="BeforeBuild">
99-
</Target>
100-
<Target Name="AfterBuild">
101-
</Target>
102-
-->
103-
</Project>
12+
13+
</Project>

snippets/visualbasic/System.Data.SqlClient/SqlCommand/BeginExecuteNonQuery/source.vb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
Option Explicit On
22
Option Strict On
3-
4-
Imports System.Data
53
' <Snippet1>
64
Imports System.Data.SqlClient
75

@@ -12,11 +10,11 @@ Module Module1
1210
' BeginExecuteNonQuery functionality.
1311
' The WAITFOR statement simply adds enough time to prove the
1412
' asynchronous nature of the command.
15-
Dim commandText As String = _
16-
"UPDATE Production.Product SET ReorderPoint = ReorderPoint + 1 " & _
17-
"WHERE ReorderPoint Is Not Null;" & _
18-
"WAITFOR DELAY '0:0:3';" & _
19-
"UPDATE Production.Product SET ReorderPoint = ReorderPoint - 1 " & _
13+
Dim commandText As String =
14+
"UPDATE Production.Product SET ReorderPoint = ReorderPoint + 1 " &
15+
"WHERE ReorderPoint Is Not Null;" &
16+
"WAITFOR DELAY '0:0:3';" &
17+
"UPDATE Production.Product SET ReorderPoint = ReorderPoint - 1 " &
2018
"WHERE ReorderPoint Is Not Null"
2119

2220
RunCommandAsynchronously(commandText, GetConnectionString())
@@ -25,7 +23,7 @@ Module Module1
2523
Console.ReadLine()
2624
End Sub
2725

28-
Private Sub RunCommandAsynchronously( _
26+
Private Sub RunCommandAsynchronously(
2927
ByVal commandText As String, ByVal connectionString As String)
3028

3129
' Given command text and connection string, asynchronously execute
@@ -46,7 +44,7 @@ Module Module1
4644
Threading.Thread.Sleep(100)
4745
count += 1
4846
End While
49-
Console.WriteLine("Command complete. Affected {0} rows.", _
47+
Console.WriteLine("Command complete. Affected {0} rows.",
5048
command.EndExecuteNonQuery(result))
5149
Catch ex As SqlException
5250
Console.WriteLine("Error ({0}): {1}", ex.Number, ex.Message)
@@ -67,7 +65,7 @@ Module Module1
6765
' If you have not included "Asynchronous Processing=true" in the
6866
' connection string, the command is not able
6967
' to execute asynchronously.
70-
Return "Data Source=(local);Integrated Security=SSPI;" & _
68+
Return "Data Source=(local);Integrated Security=SSPI;" &
7169
"Initial Catalog=AdventureWorks; Asynchronous Processing=true"
7270
End Function
7371
End Module

snippets/visualbasic/System.Data.SqlClient/SqlCommand/BeginExecuteXmlReader/Form1.vb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Option Strict On
44
Imports System.Data
55
' <Snippet1>
66
Imports System.Data.SqlClient
7+
Imports System.Windows.Forms
78
Imports System.Xml
89

910
Public Class Form1
Lines changed: 9 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,13 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project 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>8.0.50727</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{C019A781-A425-4338-9553-5D623134FD21}</ProjectGuid>
9-
<OutputType>WinExe</OutputType>
10-
<StartupObject>TesterFormVB.My.MyApplication</StartupObject>
11-
<RootNamespace>TesterFormVB</RootNamespace>
12-
<AssemblyName>TesterFormVB</AssemblyName>
13-
<MyType>WindowsForms</MyType>
14-
<OptionStrict>On</OptionStrict>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net9.0-windows</TargetFramework>
6+
<UseWindowsForms>true</UseWindowsForms>
157
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17-
<DebugSymbols>true</DebugSymbols>
18-
<DebugType>full</DebugType>
19-
<DefineDebug>true</DefineDebug>
20-
<DefineTrace>true</DefineTrace>
21-
<OutputPath>bin\Debug\</OutputPath>
22-
<DocumentationFile>TesterFormVB.xml</DocumentationFile>
23-
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
24-
</PropertyGroup>
25-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26-
<DebugType>pdbonly</DebugType>
27-
<DefineDebug>false</DefineDebug>
28-
<DefineTrace>true</DefineTrace>
29-
<Optimize>true</Optimize>
30-
<OutputPath>bin\Release\</OutputPath>
31-
<DocumentationFile>TesterFormVB.xml</DocumentationFile>
32-
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
33-
</PropertyGroup>
34-
<ItemGroup>
35-
<Reference Include="System" />
36-
<Reference Include="System.Data" />
37-
<Reference Include="System.Deployment" />
38-
<Reference Include="System.Drawing" />
39-
<Reference Include="System.Windows.Forms" />
40-
<Reference Include="System.Xml" />
41-
</ItemGroup>
42-
<ItemGroup>
43-
<Import Include="Microsoft.VisualBasic" />
44-
<Import Include="System" />
45-
<Import Include="System.Collections" />
46-
<Import Include="System.Collections.Generic" />
47-
<Import Include="System.Data" />
48-
<Import Include="System.Drawing" />
49-
<Import Include="System.Diagnostics" />
50-
<Import Include="System.Windows.Forms" />
51-
</ItemGroup>
52-
<ItemGroup>
53-
<Compile Include="Form1.vb">
54-
<SubType>Form</SubType>
55-
</Compile>
56-
<Compile Include="Form1.Designer.vb">
57-
<DependentUpon>Form1.vb</DependentUpon>
58-
<SubType>Form</SubType>
59-
</Compile>
60-
<Compile Include="My Project\AssemblyInfo.vb" />
61-
<Compile Include="My Project\Application.Designer.vb">
62-
<AutoGen>True</AutoGen>
63-
<DependentUpon>Application.myapp</DependentUpon>
64-
</Compile>
65-
<Compile Include="My Project\Resources.Designer.vb">
66-
<AutoGen>True</AutoGen>
67-
<DesignTime>True</DesignTime>
68-
<DependentUpon>Resources.resx</DependentUpon>
69-
</Compile>
70-
<Compile Include="My Project\Settings.Designer.vb">
71-
<AutoGen>True</AutoGen>
72-
<DependentUpon>Settings.settings</DependentUpon>
73-
<DesignTimeSharedInput>True</DesignTimeSharedInput>
74-
</Compile>
75-
</ItemGroup>
76-
<ItemGroup>
77-
<EmbeddedResource Include="My Project\Resources.resx">
78-
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
79-
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
80-
<CustomToolNamespace>My.Resources</CustomToolNamespace>
81-
<SubType>Designer</SubType>
82-
</EmbeddedResource>
83-
</ItemGroup>
8+
849
<ItemGroup>
85-
<None Include="My Project\Application.myapp">
86-
<Generator>MyApplicationCodeGenerator</Generator>
87-
<LastGenOutput>Application.Designer.vb</LastGenOutput>
88-
</None>
89-
<None Include="My Project\Settings.settings">
90-
<Generator>SettingsSingleFileGenerator</Generator>
91-
<CustomToolNamespace>My</CustomToolNamespace>
92-
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
93-
</None>
10+
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
9411
</ItemGroup>
95-
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
96-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
97-
Other similar extension points exist, see Microsoft.Common.targets.
98-
<Target Name="BeforeBuild">
99-
</Target>
100-
<Target Name="AfterBuild">
101-
</Target>
102-
-->
103-
</Project>
12+
13+
</Project>

0 commit comments

Comments
 (0)