Click here to Skip to main content
15,890,385 members
Home / Discussions / Web Development
   

Web Development

 
QuestionHELP Coding search button in VB Pin
ynettep28-Apr-14 14:21
ynettep28-Apr-14 14:21 
AnswerRe: HELP Coding search button in VB Pin
Richard Andrew x6428-Apr-14 14:49
professionalRichard Andrew x6428-Apr-14 14:49 
GeneralRe: HELP Coding search button in VB Pin
ynettep28-Apr-14 15:06
ynettep28-Apr-14 15:06 
AnswerRe: HELP Coding search button in VB Pin
Wes Aday28-Apr-14 15:10
professionalWes Aday28-Apr-14 15:10 
GeneralRe: HELP Coding search button in VB Pin
ynettep28-Apr-14 15:35
ynettep28-Apr-14 15:35 
GeneralRe: HELP Coding search button in VB Pin
Wes Aday29-Apr-14 1:08
professionalWes Aday29-Apr-14 1:08 
AnswerRe: HELP Coding search button in VB Pin
ZurdoDev28-Apr-14 15:53
professionalZurdoDev28-Apr-14 15:53 
SuggestionRe: HELP Coding search button in VB Pin
Richard Deeming29-Apr-14 2:26
mveRichard Deeming29-Apr-14 2:26 
vanburenp wrote:
Dim erMsg As Windows.Forms.DialogResult = MessageBox.Show("Must enter Last Name.", "Search", MessageBoxButtons.OK)

That's not going to work in an ASP.NET application. If you're lucky, the MessageBox.Show call will throw an error because the process is not interactive. If you're not lucky, the message box will be displayed on the server, where nobody will ever see it, and your page will time out.

It might appear to work when you're running the site from Visual Studio, but that's only because the server and client happen to be the same computer in that case.

Add a RequiredFieldValidator[^] to the txtLastN textbox, and change the start of your method to:
VB.NET
If Not Page.IsValid Then
    Return
End If


As to the data-binding problem, as others have mentioned, you'll need to execute the query and bind the results to your grid. You should also wrap the connection, command and data-reader objects in Using blocks to ensure that they get cleaned up as soon as they're no longer needed.
VB.NET
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
    If Not Page.IsValid Then
        Return
    End If
    
    Dim connectionString As String = ConfigurationManager.ConnectionStrings("SqlDataSource1").ConnectionString
    Dim commandText As String = "SELECT FirstName, LastName, SSN from tblMAGIapplications where (FirstName = @FirstName and LastName = @LastName) or (SSN = @SSN)"
    
    Using conn As New Data.SqlClient.SqlConnection(connectionString)
        Using cmd As New Data.SqlClient.SqlCommand(commandText, conn)
            
            cmd.Parameters.AddWithValue("@FirstName", Me.txtFirstN.Text)
            cmd.Parameters.AddWithValue("@LastName", Me.txtLastN.Text)
            
            ' NB: You still need to add the SSN parameter, as the query uses it:
            cmd.Parameters.AddWithValue("@SSN", 0) 
            
            Using reader As Data.SqlClient.SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
                GridView1.DataSource = reader
                GridView1.DataBind()
            End Using
        End Using
    End Using
End Sub




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


QuestionDrag-nDrop in ASP.NET Pin
Bheem Sen Singh28-Apr-14 1:43
professionalBheem Sen Singh28-Apr-14 1:43 
AnswerRe: Drag-nDrop in ASP.NET Pin
ZurdoDev28-Apr-14 16:05
professionalZurdoDev28-Apr-14 16:05 
GeneralRe: Drag-nDrop in ASP.NET Pin
Bheem Sen Singh25-Jun-14 23:33
professionalBheem Sen Singh25-Jun-14 23:33 
QuestionI would like to have your advice to finish a big non-profit social project Pin
Pedro197027-Apr-14 13:09
Pedro197027-Apr-14 13:09 
QuestionRe: I would like to have your advice to finish a big non-profit social project Pin
ZurdoDev28-Apr-14 16:06
professionalZurdoDev28-Apr-14 16:06 
AnswerRe: I would like to have your advice to finish a big non-profit social project Pin
Pedro19701-May-14 12:20
Pedro19701-May-14 12:20 
AnswerRe: I would like to have your advice to finish a big non-profit social project Pin
ZurdoDev1-May-14 15:03
professionalZurdoDev1-May-14 15:03 
GeneralRe: I would like to have your advice to finish a big non-profit social project Pin
Pedro19703-May-14 11:03
Pedro19703-May-14 11:03 
GeneralRe: I would like to have your advice to finish a big non-profit social project Pin
hsuhsutin15-May-14 17:30
hsuhsutin15-May-14 17:30 
QuestionHow to pass parameter from one jQuery tab to another (Solved) Pin
samflex27-Apr-14 6:00
samflex27-Apr-14 6:00 
AnswerRe: How to pass parameter from one jQuery tab to another Pin
Richard Deeming28-Apr-14 2:26
mveRichard Deeming28-Apr-14 2:26 
GeneralRe: How to pass parameter from one jQuery tab to another Pin
samflex28-Apr-14 5:15
samflex28-Apr-14 5:15 
GeneralRe: How to pass parameter from one jQuery tab to another Pin
Richard Deeming28-Apr-14 5:21
mveRichard Deeming28-Apr-14 5:21 
GeneralRe: How to pass parameter from one jQuery tab to another Pin
samflex28-Apr-14 5:27
samflex28-Apr-14 5:27 
QuestionJssor SlideShow Default Image Pin
Jassim Rahma25-Apr-14 9:11
Jassim Rahma25-Apr-14 9:11 
Questionhow to paginate like linkedin and facebook? Pin
Jassim Rahma25-Apr-14 6:31
Jassim Rahma25-Apr-14 6:31 
AnswerRe: how to paginate like linkedin and facebook? Pin
onelopez25-Apr-14 6:50
onelopez25-Apr-14 6:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.