Advertisement

09.12.2005 at 08:15AM PDT, ID: 21558375
[x]
Attachment Details

Search Results Returned to a Datagrid

Asked by earngreen in Microsoft Visual Basic.Net

Tags: dasearch, oledbdataadapter, seaweb

I am building a Windows form with multiple search critea that is returned to a datagrid on the same page for editing etc. I can search some criteria but it returns no results to the datagrid. I  am basically looking to ask why the results are not being displayed or if anyone has a simplier way for doing this process.

Thanks

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim strSQL As String

       
        Dim searchStr As String = ""
        Dim cnt As Integer = 0

       
        Dim sqlStr As String = "SELECT SeaWeb.* FROM SeaWeb;"
        Dim connectStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=D:\SeaWeb\SeaWeb.mdb;"
        Dim cnn1 As New OleDbConnection(connectStr)

        ' Build the search string.
        searchStr = BuildSearchString(sqlStr)

        cnn1.Open()

       
        Dim sqlCmd As New OleDbCommand(searchStr, cnn1)

       
        If cmbVendorName.SelectedItem.Text = "" And cmbTimekeeper.SelectedItem.Text = "" _
            And txtMatterNum.Text = "" And txtBegDate.Text = "" _
            And txtEndDate.Text = "" Then
            MsgBox("You must use at least one search criteria.")
            Exit Sub
            BindDataGrid()
            cnn1.Close()

    End Sub

    Private Function BuildSearchString(ByVal sqlstr As String) As String
       
        sqlstr = ""
        'If cmbVName.SelectedItem.Text <> " " Then
        '    If sqlstr = " " Then
        '        sqlstr = sqlstr & "(VName like " & """" & "%" & cmbVName.SelectedItem.Text & "%""" & ")"
        '    Else
        '        sqlstr = sqlstr & "(VName like " & """" & "%" & cmbVName.SelectedItem.Text & "%""" & ")"

        '    End If
        'End If
        ''Gets SQL from drop down list for Timekeeper name
        'If cmbTime.SelectedItem.Text <> "" Then
        '    If sqlstr = " " Then
        '        sqlstr = sqlstr & "(AName like " & """" & "%" & cmbTime.SelectedItem.Text & "%""" & ")"
        '    Else
        '        sqlstr = sqlstr & "(AName like " & """" & "%" & cmbTime.SelectedItem.Text & "%""" & ")"
        '    End If
        'End If

        ''Gets Search critia from Matter Number Entered

        If txtMNum.Text <> " " Then
            If sqlstr = " " Then
                sqlstr = sqlstr & "(MNum like " & """" & "%" & txtMNum.Text & "%""" & ")"
            Else
                sqlstr = sqlstr & "(MNum like " & """" & "%" & txtMNum.Text & "%""" & ")"
            End If
        End If

        If txtBegDate.Text <> " " Then
            If sqlstr = " " Then
                sqlstr = sqlstr & "(OrderTime like " & """" & "%" & txtBegDate.Text & "%""" & ")"
            Else
                sqlstr = sqlstr & "(OrderTime like " & """" & "%" & txtBegDate.Text & "%""" & ")"
            End If
        End If
        If txtEndDate.Text <> " " Then
            If sqlstr = " " Then
                sqlstr = sqlstr & "(OrderTime like " & """" & "%" & txtEndDate.Text & "%""" & ")"
            Else
                sqlstr = sqlstr & "(OrderTime like " & """" & "%" & txtEndDate.Text & "%""" & ")"
            End If
        End If
        'If cmbVName.SelectedItem.Text = "  " And cmbTime.SelectedItem.Text = "" And txtMNum.Text = "" Then

     

    End Function

      Sub BindDataGrid()

        Dim myDataTable As New DataTable
       dgSearchResults.DataSource = myDataTable

        Dim msqlStr As String = "SELECT SeaWeb.* FROM SeaWeb;"
        msqlStr = "SELECT SeaWeb.* FROM SeaWeb"
        Dim DBConn As System.Data.OleDb.OleDbConnection
        Dim DaSearch As New OleDbDataAdapter(msqlStr, DBCOnn)
        Dim DsSearch As SeaWeb8_22_05.FrmSeaWeb

        DsSeaWeb.Clear()
        OleDbDataAdapter1.Fill(DsSeaWeb)


    End Sub
Start Free Trial
[+][-]09.12.2005 at 08:42AM PDT, ID: 14864849

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 08:51AM PDT, ID: 14864914

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 08:55AM PDT, ID: 14864955

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 09:06AM PDT, ID: 14865046

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 09:09AM PDT, ID: 14865079

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 09:12AM PDT, ID: 14865104

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 09:32AM PDT, ID: 14865273

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 09:50AM PDT, ID: 14865408

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 10:38AM PDT, ID: 14865742

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 10:42AM PDT, ID: 14865769

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 10:58AM PDT, ID: 14865939

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 11:01AM PDT, ID: 14865967

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 11:44AM PDT, ID: 14866307

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 12:15PM PDT, ID: 14866640

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 12:30PM PDT, ID: 14866783

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 12:34PM PDT, ID: 14866823

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 12:35PM PDT, ID: 14866840

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 01:42PM PDT, ID: 14867393

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2005 at 03:44PM PDT, ID: 14868125

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.13.2005 at 12:56PM PDT, ID: 14875238

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.13.2005 at 03:11PM PDT, ID: 14876313

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.13.2005 at 04:20PM PDT, ID: 14876592

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: dasearch, oledbdataadapter, seaweb
Sign Up Now!
Solution Provided By: Sancler
Participating Experts: 3
Solution Grade: A
 
 
[+][-]09.14.2005 at 09:19AM PDT, ID: 14882126

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32