Click here to Skip to main content
15,886,664 members
Articles / Desktop Programming / Windows Forms

MS Access Databases Queries Editor

Rate me:
Please Sign up or sign in to vote.
4.91/5 (23 votes)
26 Jul 2009GPL38 min read 152.3K   9.5K   116  
A very productive, easy to use tool to edit your Sql Queries against MS Access Databases
Public Class frm_AddParams

    Private Sub Closing_Clicks(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles btn_OK.Click, btn_Cancel.Click

        
        If DialogResult = Windows.Forms.DialogResult.Cancel Then
            Close()
            Exit Sub
        End If

        Try

            DGV_Params.AllowUserToAddRows = False 'remove the last Null row
            Dim NotWanted As Object() = New Object() {"", DBNull.Value, Nothing}

            Query.QueryParams.Clear()
            For Each Row As DataGridViewRow In _
                   From DGV_Row As DataGridViewRow In DGV_Params.Rows _
                   Where Not NotWanted.Contains(DGV_Row.Cells(0).Value) And _
                         Not NotWanted.Contains(DGV_Row.Cells(1).Value)


                
                Query.QueryParams.Add(CType(Row.Cells(0).Value, String), _
                                CType(Row.Cells(1).Value, String))
            Next
            Close()
        Catch ex As Exception

            MsgBox("Error Encountered" & Environment.NewLine & Environment.NewLine & _
                   ex.Message, _
                   MsgBoxStyle.Exclamation, "Caution")
            DialogResult = Windows.Forms.DialogResult.Cancel

        End Try

    End Sub

    Private Sub frm_AddParams_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Escape Then
            Me.btn_Cancel.PerformClick()
        End If
    End Sub

    Private Sub frm_AddParams_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DGV_Params.Rows.Clear()

        If Query.QueryParams IsNot Nothing AndAlso Query.QueryParams.Count > 0 Then

            For Each P In Query.QueryParams
                DGV_Params.Rows.Add(New Object() {P.Key, P.Value})
            Next

        End If
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer
Syrian Arab Republic Syrian Arab Republic
The more I learn the more I see my ignorance.

Comments and Discussions