Code behind
Imports System.Web.UI
Imports System.Data.Sql
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
'acquire the ad id
Dim adLookupCS As String = ConfigurationManager.ConnectionStrings +
("My_ConnectionString1").ToString
Dim adLookupConn As New SqlConnection(adLookupCS)
Dim adLookupCmd As New SqlCommand("SELECT * FROM recordLookup;", adLookupConn)
Dim adLookupRdr As SqlDataReader
Try
adLookupCmd.Connection.Open()
adLookupRdr = adLookupCmd.ExecuteReader()
If adLookupRdr.Read() Then
adNumber.Text = adLookupRdr(0)
Try
Dim adLNUpdCon As String = ConfigurationManager.ConnectionStrings +
("My_ConnectionString1").ToString
Dim adLNUpdStr As String = "UPDATE ss_ad_lookup SET lookupNumber = @lkNumb"
Dim count As Integer = adLookupRdr(0) + 1
Dim SQLConn As New SqlConnection()
Dim SQLCmd As New SqlCommand()
SQLConn.ConnectionString = adLNUpdCon
SQLConn.Open()
'define parameters
SQLCmd.Parameters.AddWithValue("@lkNumb", count)
SQLCmd.Connection = SQLConn
SQLCmd.CommandText = adLNUpdStr
SQLCmd.ExecuteNonQuery() 'execute SQL connection
SQLConn.Close()
SQLConn.Dispose()
Catch ex As Exception
'ex.Message.ToString()
End Try
End If
Catch ex As Exception
'ex.Message.ToString()
End Try
adLookupCmd.Connection.Close()
adLookupCmd.Dispose()
End Sub
End Class