We help IT Professionals succeed at work.
Get Started

main form click search on another form asp.net

826 Views
Last Modified: 2013-12-25
I need to figure out how to connect a search form with my main form and have it actually search and populate the form. It would be on Patient_name. Right now my form will populate the database when i click update and it will also clear the contents for the next record and move to the next record it.

HELP PLEASE!!!
Imports System.Data
Imports System.Data.SqlClient
Imports System
Imports System.Configuration
Imports System.Data.DataRowView
 
Partial Public Class pagedesign
    Inherits System.Web.UI.Page
    Public myConnectionString As String = ConfigurationManager.ConnectionStrings("reflabconnectionstring").ConnectionString
 
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim dbcon As New SqlConnection(ConfigurationManager.ConnectionStrings.Item("reflabconnectionstring").ConnectionString)
        dbcon.Open()
        Dim dbcmd As New SqlCommand
        dbcmd.Connection = dbcon
        dbcmd.CommandText = "Select Max(RecordID) From tbl_general"
        Dim RecordID As Integer = dbcmd.ExecuteScalar()
        RecordID = RecordID + 1
        Me.Recordid.Text = RecordID
        dbcmd.Dispose()
        dbcon.Dispose()
    End Sub
 
    Protected Sub Update_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Update.Click
        Using connection = New SqlConnection(myConnectionString)
            Dim Command = New SqlCommand("RefLabProcedure", connection)
            Command.CommandType = CommandType.StoredProcedure
            Command.Parameters.Add("@patient_id", Data.SqlDbType.VarChar).Value = Patient_id.Text
            Command.Parameters.Add("@patient_name", Data.SqlDbType.VarChar).Value = Patient_Name.Text
            Command.Parameters.Add("@hospital_name", Data.SqlDbType.VarChar).Value = hospital_Name.Text
            Command.Parameters.Add("@testing_date", Data.SqlDbType.VarChar).Value = Testing_Date.Text
            Command.Parameters.Add("@abo_rh", Data.SqlDbType.VarChar).Value = ABO_Rh.SelectedIndex
            Command.Parameters.Add("@ant_a1", Data.SqlDbType.Bit).Value = Ant_A1.Checked
            Command.Parameters.Add("@ant_fya", Data.SqlDbType.Bit).Value = Ant_Fya.Checked
            Command.Parameters.Add("@ant_fyb", Data.SqlDbType.Bit).Value = Ant_FYb.Checked
            Command.Parameters.Add("@ant_kell", Data.SqlDbType.Bit).Value = Ant_Kell.Checked
            Command.Parameters.Add("@ant_little_k", Data.SqlDbType.Bit).Value = Ant_little_k.Checked
            Command.Parameters.Add("@ant_jkb", Data.SqlDbType.Bit).Value = Ant_JKb.Checked
            Command.Parameters.Add("@ant_jka", Data.SqlDbType.Bit).Value = Ant_JKa.Checked
            Command.Parameters.Add("@ant_lea", Data.SqlDbType.Bit).Value = Ant_LEa.Checked
            Command.Parameters.Add("@ant_leb", Data.SqlDbType.Bit).Value = Ant_LEb.Checked
            Command.Parameters.Add("@ant_s", Data.SqlDbType.Bit).Value = Ant_S.Checked
            Command.Parameters.Add("@ant_little_s", Data.SqlDbType.Bit).Value = Ant_little_s.Checked
            Command.Parameters.Add("@ant_n", Data.SqlDbType.Bit).Value = Ant_N.Checked
            Command.Parameters.Add("@ant_m", Data.SqlDbType.Bit).Value = Ant_M.Checked
            Command.Parameters.Add("@ant_p1", Data.SqlDbType.Bit).Value = Ant_P1.Checked
            Command.Parameters.Add("@ant_other", Data.SqlDbType.Bit).Value = Ant_Other.Checked
            Command.Parameters.Add("@ant_little_c", Data.SqlDbType.Bit).Value = Ant_little_c.Checked
            Command.Parameters.Add("@ant_c", Data.SqlDbType.Bit).Value = Ant_C.Checked
            Command.Parameters.Add("@ant_little_e", Data.SqlDbType.Bit).Value = Ant_little_e.Checked
            Command.Parameters.Add("@ant_e", Data.SqlDbType.Bit).Value = Ant_E.Checked
            Command.Parameters.Add("@plateletantscreen", Data.SqlDbType.VarChar).Value = PlateletAntScreen.SelectedIndex
            Command.Parameters.Add("@transfuse", Data.SqlDbType.VarChar).Value = Transfuse.Text
            Command.Parameters.Add("@testingperformedby", Data.SqlDbType.VarChar).Value = TestingPerformedBy.Text
            Command.Parameters.Add("@reviewedby", Data.SqlDbType.VarChar).Value = ReviewedBy.Text
            Command.Parameters.Add("@drugstudy", Data.SqlDbType.VarChar).Value = DrugStudy.Text
            Command.Parameters.Add("@adsorption", Data.SqlDbType.VarChar).Value = Adsorption.SelectedIndex
            Command.Parameters.Add("@dat1", Data.SqlDbType.VarChar).Value = DAT1.SelectedIndex
            Command.Parameters.Add("@dat2", Data.SqlDbType.VarChar).Value = DAT2.SelectedIndex
            Command.Parameters.Add("@reticseparation", Data.SqlDbType.VarChar).Value = ReticSeparation.SelectedIndex
            Command.Parameters.Add("@reactiveat", Data.SqlDbType.VarChar).Value = ReactiveAt.SelectedIndex
            Command.Parameters.Add("@discrepancyresolution", Data.SqlDbType.VarChar).Value = DiscrepancyResolution.Text
            Command.Parameters.Add("@datereceived", Data.SqlDbType.VarChar).Value = DateRecieved.Text
            Command.Parameters.Add("@datesampled", Data.SqlDbType.VarChar).Value = DateSampled.Text
            Command.Parameters.Add("@reactiveat2", Data.SqlDbType.VarChar).Value = ReactiveAt2.Text
            Command.Parameters.Add("@rhphenotype", Data.SqlDbType.VarChar).Value = RHPhenotype.SelectedIndex
            Command.Parameters.Add("@other", Data.SqlDbType.VarChar).Value = Other.Text
            Command.Parameters.Add("@antibodyidperformed", Data.SqlDbType.Bit).Value = AntibodyIDPerformed.Checked
            Command.Parameters.Add("@elutionperformed", Data.SqlDbType.Bit).Value = ElutionPerformed.Checked
            Command.Parameters.Add("@adsorptionPerformed", Data.SqlDbType.Bit).Value = AdsorptionPerformed.Checked
            Command.Parameters.Add("@1_ant_a1", Data.SqlDbType.Bit).Value = Ant_A11.Checked
            Command.Parameters.Add("@1_ant_fya", Data.SqlDbType.Bit).Value = Ant_FYa1.Checked
            Command.Parameters.Add("@1_ant_fyb", Data.SqlDbType.Bit).Value = Ant_FYb1.Checked
            Command.Parameters.Add("@1_ant_kell", Data.SqlDbType.Bit).Value = Ant_Kell1.Checked
            Command.Parameters.Add("@1_ant_k", Data.SqlDbType.Bit).Value = Ant_k1.Checked
            Command.Parameters.Add("@1_ant_jkb", Data.SqlDbType.Bit).Value = Ant_JKb1.Checked
            Command.Parameters.Add("@1_ant_jka", Data.SqlDbType.Bit).Value = Ant_JKa1.Checked
            Command.Parameters.Add("@1_ant_lea", Data.SqlDbType.Bit).Value = Ant_LEa1.Checked
            Command.Parameters.Add("@1_ant_leb", Data.SqlDbType.Bit).Value = Ant_LEb1.Checked
            Command.Parameters.Add("@1_ant_s", Data.SqlDbType.Bit).Value = Ant_S1.Checked
            Command.Parameters.Add("@1_ant_little_s", Data.SqlDbType.Bit).Value = Ant_little_s1.Checked
            Command.Parameters.Add("@1_ant_n", Data.SqlDbType.Bit).Value = Ant_N1.Checked
            Command.Parameters.Add("@1_ant_m", Data.SqlDbType.Bit).Value = Ant_M1.Checked
            Command.Parameters.Add("@1_ant_p1", Data.SqlDbType.Bit).Value = Ant_P11.Checked
            Command.Parameters.Add("@1_ant_Other", Data.SqlDbType.Bit).Value = Ant_Other1.Checked
            Command.Parameters.Add("@1_other", Data.SqlDbType.VarChar).Value = Other1.Text
            Command.Parameters.Add("@1_ant_little_c", Data.SqlDbType.Bit).Value = Ant_littlec1.Checked
            Command.Parameters.Add("@1_ant_c", Data.SqlDbType.Bit).Value = Ant_C1.Checked
            Command.Parameters.Add("@1_ant_little_e", Data.SqlDbType.Bit).Value = Ant_little_e1.Checked
            Command.Parameters.Add("@1_ant_e", Data.SqlDbType.Bit).Value = Ant_E1.Checked
            Command.Parameters.Add("@2_ant_a1", Data.SqlDbType.Bit).Value = Ant_A12.Checked
            Command.Parameters.Add("@2_ant_fya", Data.SqlDbType.Bit).Value = Ant_FYa2.Checked
            Command.Parameters.Add("@2_ant_fyb", Data.SqlDbType.Bit).Value = Ant_FYb2.Checked
            Command.Parameters.Add("@2_ant_kell", Data.SqlDbType.Bit).Value = Ant_Kell2.Checked
            Command.Parameters.Add("@2_ant_k", Data.SqlDbType.Bit).Value = Ant_k2.Checked
            Command.Parameters.Add("@2_ant_jkb", Data.SqlDbType.Bit).Value = Ant_JKb2.Checked
            Command.Parameters.Add("@2_ant_jka", Data.SqlDbType.Bit).Value = Ant_JKa2.Checked
            Command.Parameters.Add("@2_ant_lea", Data.SqlDbType.Bit).Value = Ant_LEa2.Checked
            Command.Parameters.Add("@2_ant_leb", Data.SqlDbType.Bit).Value = Ant_LEb2.Checked
            Command.Parameters.Add("@2_ant_s", Data.SqlDbType.Bit).Value = Ant_S2.Checked
            Command.Parameters.Add("@2_ant_little_s", Data.SqlDbType.Bit).Value = Ant_little_s2.Checked
            Command.Parameters.Add("@2_ant_n", Data.SqlDbType.Bit).Value = Ant_N2.Checked
            Command.Parameters.Add("@2_ant_m", Data.SqlDbType.Bit).Value = Ant_M2.Checked
            Command.Parameters.Add("@2_ant_p1", Data.SqlDbType.Bit).Value = Ant_P12.Checked
            Command.Parameters.Add("@2_ant_other", Data.SqlDbType.Bit).Value = Ant_Other2.Checked
            Command.Parameters.Add("@2_other", Data.SqlDbType.VarChar).Value = Other2.Text
            Command.Parameters.Add("@2_ant_little_c", Data.SqlDbType.Bit).Value = Ant_little_c2.Checked
            Command.Parameters.Add("@2_ant_c", Data.SqlDbType.Bit).Value = Ant_C2.Checked
            Command.Parameters.Add("@2_ant_little_e", Data.SqlDbType.Bit).Value = Ant_little_e2.Checked
            Command.Parameters.Add("@2_ant_e", Data.SqlDbType.Bit).Value = Ant_E2.Checked
            Command.Parameters.Add("@3_ant_a1", Data.SqlDbType.Bit).Value = Ant_A13.Checked
            Command.Parameters.Add("@3_ant_fya", Data.SqlDbType.Bit).Value = Ant_FYa3.Checked
            Command.Parameters.Add("@3_ant_fyb", Data.SqlDbType.Bit).Value = Ant_FYb3.Checked
            Command.Parameters.Add("@3_ant_kell", Data.SqlDbType.Bit).Value = Ant_Kell3.Checked
            Command.Parameters.Add("@3_ant_k", Data.SqlDbType.Bit).Value = Ant_k3.Checked
            Command.Parameters.Add("@3_ant_jkb", Data.SqlDbType.Bit).Value = Ant_JKb3.Checked
            Command.Parameters.Add("@3_ant_jka", Data.SqlDbType.Bit).Value = Ant_JKa3.Checked
            Command.Parameters.Add("@3_ant_lea", Data.SqlDbType.Bit).Value = Ant_LEa3.Checked
            Command.Parameters.Add("@3_ant_leb", Data.SqlDbType.Bit).Value = Ant_LEb3.Checked
            Command.Parameters.Add("@3_ant_s", Data.SqlDbType.Bit).Value = Ant_S3.Checked
            Command.Parameters.Add("@3_ant_little_s", Data.SqlDbType.Bit).Value = Ant_little_s3.Checked
            Command.Parameters.Add("@3_ant_n", Data.SqlDbType.Bit).Value = Ant_N3.Checked
            Command.Parameters.Add("@3_ant_m", Data.SqlDbType.Bit).Value = Ant_M3.Checked
            Command.Parameters.Add("@3_ant_p1", Data.SqlDbType.Bit).Value = Ant_P13.Checked
            Command.Parameters.Add("@3_ant_other", Data.SqlDbType.Bit).Value = Ant_Other3.Checked
            Command.Parameters.Add("@3_other", Data.SqlDbType.VarChar).Value = Other3.Text
            Command.Parameters.Add("@3_ant_little_c", Data.SqlDbType.Bit).Value = Ant_little_c3.Checked
            Command.Parameters.Add("@3_ant_c", Data.SqlDbType.Bit).Value = Ant_C3.Checked
            Command.Parameters.Add("@3_ant_little_e", Data.SqlDbType.Bit).Value = Ant_little_e3.Checked
            Command.Parameters.Add("@3_ant_e", Data.SqlDbType.Bit).Value = Ant_E3.Checked
            Command.Parameters.Add("@patientantigentyping", Data.SqlDbType.Bit).Value = PatientAntigenTyping.Checked
            Command.Parameters.Add("@recordid", Data.SqlDbType.VarChar).Value = Recordid.Text
            Command.Parameters.Add("@3_ant_d", Data.SqlDbType.Bit).Value = Ant_D3.Checked
            Command.Parameters.Add("@2_ant_d", Data.SqlDbType.Bit).Value = Ant_D2.Checked
            Command.Parameters.Add("@1_ant_d", Data.SqlDbType.Bit).Value = Ant_D1.Checked
            Command.Parameters.Add("@ant_d", Data.SqlDbType.Bit).Value = Ant_D.Checked
            Command.Parameters.Add("@free_text", Data.SqlDbType.VarChar).Value = Free_Text.Text
            Command.Parameters.Add("@dob", Data.SqlDbType.DateTime).Value = DOB.Text
            connection.Open()
            Try
                Command.ExecuteNonQuery()
            Catch ex As Exception
                Response.Write("Error Occured. Details: " & ex.Message)
            End Try
        End Using
 
 
    End Sub
 
 
    Protected Sub cmdnew_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdnew.Click
        Using connection = New SqlConnection(myConnectionString)
            Dim Command = New SqlCommand("RefLabProcedure", connection)
            Command.CommandType = CommandType.StoredProcedure
            Patient_id.Text = ""
            Patient_Name.Text = ""
            Hospital_Name.Text = ""
            Testing_Date.Text = ""
            ABO_Rh.SelectedIndex = 0
            Ant_A1.Checked = 0
            Ant_Fya.Checked = 0
            Ant_FYb.Checked = 0
            Ant_Kell.Checked = 0
            Ant_little_k.Checked = 0
            Ant_JKb.Checked = 0
            Ant_JKa.Checked = 0
            Ant_LEa.Checked = 0
            Ant_LEb.Checked = 0
            Ant_S.Checked = 0
            Ant_little_s.Checked = 0
            Ant_N.Checked = 0
            Ant_M.Checked = 0
            Ant_P1.Checked = 0
            Ant_Other.Checked = 0
            Ant_little_c.Checked = 0
            Ant_C.Checked = 0
            Ant_little_e.Checked = 0
            Ant_E.Checked = 0
            PlateletAntScreen.SelectedIndex = 0
            Transfuse.Text = 0
            TestingPerformedBy.Text = ""
            ReviewedBy.Text = ""
            DrugStudy.Text = ""
            Adsorption.SelectedIndex = 0
            DAT1.SelectedIndex = 0
            DAT2.SelectedIndex = 0
            ReticSeparation.SelectedIndex = 0
            ReactiveAt.SelectedIndex = 0
            DiscrepancyResolution.Text = ""
            DateRecieved.Text = ""
            DateSampled.Text = ""
            ReactiveAt2.Text = ""
            RHPhenotype.SelectedIndex = 0
            Other.Text = ""
            AntibodyIDPerformed.Checked = 0
            ElutionPerformed.Checked = 0
            AdsorptionPerformed.Checked = 0
            Ant_A11.Checked = 0
            Ant_FYa1.Checked = 0
            Ant_FYb1.Checked = 0
            Ant_Kell1.Checked = 0
            Ant_k1.Checked = 0
            Ant_JKb1.Checked = 0
            Ant_JKa1.Checked = 0
            Ant_LEa1.Checked = 0
            Ant_LEb1.Checked = 0
            Ant_S1.Checked = 0
            Ant_little_s1.Checked = 0
            Ant_N1.Checked = 0
            Ant_M1.Checked = 0
            Ant_P11.Checked = 0
            Ant_Other1.Checked = 0
            Other1.Text = ""
            Ant_littlec1.Checked = 0
            Ant_C1.Checked = 0
            Ant_little_e1.Checked = 0
            Ant_E1.Checked = 0
            Ant_A12.Checked = 0
            Ant_FYa2.Checked = 0
            Ant_FYb2.Checked = 0
            Ant_Kell2.Checked = 0
            Ant_k2.Checked = 0
            Ant_JKb2.Checked = 0
            Ant_JKa2.Checked = 0
            Ant_LEa2.Checked = 0
            Ant_LEb2.Checked = 0
            Ant_S2.Checked = 0
            Ant_little_s2.Checked = 0
            Ant_N2.Checked = 0
            Ant_M2.Checked = 0
            Ant_P12.Checked = 0
            Ant_Other2.Checked = 0
            Other2.Text = ""
            Ant_little_c2.Checked = 0
            Ant_C2.Checked = 0
            Ant_little_e2.Checked = 0
            Ant_E2.Checked = 0
            Ant_A13.Checked = 0
            Ant_FYa3.Checked = 0
            Ant_FYb3.Checked = 0
            Ant_Kell3.Checked = 0
            Ant_k3.Checked = 0
            Ant_JKb3.Checked = 0
            Ant_JKa3.Checked = 0
            Ant_LEa3.Checked = 0
            Ant_LEb3.Checked = 0
            Ant_S3.Checked = 0
            Ant_little_s3.Checked = 0
            Ant_N3.Checked = 0
            Ant_M3.Checked = 0
            Ant_P13.Checked = 0
            Ant_Other3.Checked = 0
            Other3.Text = ""
            Ant_little_c3.Checked = 0
            Ant_C3.Checked = 0
            Ant_little_e3.Checked = 0
            Ant_E3.Checked = 0
            PatientAntigenTyping.Checked = 0
            Command.Parameters.Add("@recordid", Data.SqlDbType.VarChar).Value = Recordid.Text
            Ant_D3.Checked = 0
            Ant_D2.Checked = 0
            Ant_D1.Checked = 0
            Ant_D.Checked = 0
            Free_Text.Text = ""
            DOB.Text = ""
            connection.Open()
            Try
                Command.ExecuteNonQuery()
            Catch ex As Exception
                Response.Write("Error Occured. Details: " & ex.Message)
            End Try
        End Using
    End Sub
 
    Protected Sub Save_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Save.Click
 
    End Sub
 
    Protected Sub cmdnew0_Click(ByVal sender As Object, ByVal e As EventArgs) Handles search.Click
 
    End Sub
End Class

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 45 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE