Hello Sir,
Thank you so much for your help.
I have used the Stored Procedure and the code. The status is working fine.
Stored Procedure is working fine for all three fields, but the vb code is not returning any values for the M number and the Surname. I have added the VB below.
Please advice.
Many Thanks
Using con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Database_Connection_Lookups").ConnectionString)
Using cmd As SqlCommand = New SqlCommand("usp_GetRecordbySurnamePMRefStatus", con)
cmd.CommandType = CommandType.StoredProcedure
If Not String.IsNullOrEmpty(txtsearch.Text.Trim()) Then
cmd.Parameters.AddWithValue("@LastName", txtsearch.Text.Trim())
Else
cmd.Parameters.AddWithValue("@LastName", DBNull.Value)
End If
If Not String.IsNullOrEmpty(txtsearch.Text.Trim()) Then
cmd.Parameters.AddWithValue("@PMRef", txtsearch.Text.Trim())
Else
cmd.Parameters.AddWithValue("@PMRef", DBNull.Value)
End If
If ddlstatussearch.SelectedItem.Value <> "" Then
cmd.Parameters.AddWithValue("@RecordStatus", ddlstatussearch.SelectedItem.Text)
Else
cmd.Parameters.AddWithValue("@RecordStatus", DBNull.Value)
End If
Using sda As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim dt As DataTable = New DataTable()
sda.Fill(dt)
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
End Using
End Using
End Using