Imports System.Windows.Forms
Partial Class ExisitingApplication
Inherits System.Web.UI.Page
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
If Me.txtLastN.Text = "" Then
Dim erMsg As Windows.Forms.DialogResult = MessageBox.Show("Must enter Last Name.", "Search", MessageBoxButtons.OK)
End If
'Define connection string with datasource
Dim str As String = ConfigurationManager.ConnectionStrings("SqlDataSource1").ToString
'Define sql statement to be used
Dim strUSRACCESS As String = "SELECT FirstName, LastName, SSN from tblMAGIapplications where (FirstName = @FirstName and LastName = @LastName) or (SSN = @SSN) "
'Define sql connection using connection string defined above
Dim USRconn1 As New Data.SqlClient.SqlConnection(str)
'Define the compelete sql statement with connection and sql string
Dim CMD As New Data.SqlClient.SqlCommand(strUSRACCESS, USRconn1)
'Define reader for sql information returned
Dim drUSR As Data.SqlClient.SqlDataReader = (0)
'Open SQL Connection
USRconn1.Open()
'Dim number As Integer
'If Int32.TryParse(Me.txtSS.Text, number) = True Then
'CMD.Parameters.AddWithValue("@SSN", number)
'Else
'CMD.Parameters.AddWithValue("@SSN", 0)
'End If
'Add parameters
CMD.Parameters.AddWithValue("@FirstName", Me.txtFirstN.Text)
CMD.Parameters.AddWithValue("@LastName", Me.txtLastN.Text)
'CMD.Parameters.AddWithValue("@SSN", Int32.TryParse(Me.TextBox1.Text, number))
''SqlDataSource1.DataBind()
''Me.GridView1.DataSourceID = SqlDataSource1
GridView1.DataSourceID = String.Empty
GridView1.DataBind()
USRconn1.Close()
End Sub
End Class