Developing and Deploying SQL Sever Apps on Windows Integrity

25 of 39
5. Click the Design Script Tab. It opens the Visual Studio Application designer. Cut and
paste the following lines of VB .NET code.
' Microsoft SQL Server Integration Services Script Task
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Data.SqlClient
Imports System.Data.Common
Public Class ScriptMain
Public Sub Main()
Dim strConnection As String
strConnection = "Data
Source=Integrityrx1620;Initial
Catalog=AdventureWorks;Integrated Security=True"
Dim connection As New SqlConnection(strConnection)
connection.Open()
Dim strQuery As String
strQuery = "select max(AddressID) from Address"
Dim command As New SqlCommand(strQuery, connection)
Dim srReader As SqlDataReader
srReader = command.ExecuteReader()
Dim strTheId As String
'Default
strTheId = "32521"
While (srReader.Read())
strTheId = srReader.Item(0).ToString
End While