none
Data Binding stil getting the best of me. RRS feed

  • Question

  • I am using code from Xingyu Zhao it seems simple enuf but I got one more problem.   

    I keep getting an error "Additional infomation: Syntax error in FROM clouse.  on this line  "Dim reader = cmd.ExecuteReader()" I got no clue what this is about.

     Private connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\MainDishes.accdb"
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
            Using myConn As OleDbConnection = New OleDbConnection(connString)
                myConn.Open()
                Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                ListBox1.Items.Clear()
    
                For Each row As DataRow In dtNames.Rows
                    Dim tablename As String = CStr(row(2))
                    ListBox1.Items.Add(tablename)
                Next
            End Using
        End Sub
    
        Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
            Dim tableName As String = ListBox1.SelectedItem.ToString()
    
            Using myConn As OleDbConnection = New OleDbConnection(connString)
                myConn.Open()
                Dim cmdText As String = "SELECT * FROM {Main Dishes}"
    
                Using cmd As OleDbCommand = New OleDbCommand(cmdText, myConn)
                    Dim reader = cmd.ExecuteReader()
    
                    While reader.Read()
                        TextBox1.Text = reader("ID").ToString()
                        TextBox2.Text = reader("Recipe Name").ToString()
                        TextBox3.Text = reader("Caption").ToString()
                        TextBox4.Text = reader("Delivery").ToString()
                        TextBox5.Text = reader("Con1").ToString()
                        TextBox6.Text = reader("Con2").ToString()
                        TextBox7.Text = reader("Con3").ToString()
                    End While
                End Using
            End Using
        End Sub


    Monday, January 20, 2020 6:54 PM

Answers

  • Suppose we can reduce how many lines of code you have currently to open a database.

    Add this class to your project.

    Public Class DatabaseItem 
        Public Property DisplayName() As  String
        Public Property Path() As String
        Public Overrides Function ToString() As String
            Return DisplayName
        End Function
    End Class

    Add the following module to your project

    Public Module DatabaseContainer
        Public Function List As List(Of DatabaseItem)
            Dim results = new List(Of DatabaseItem)
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Smaaklik Tuisgemaakte Drankies", 
                           .Path = "M:\My Documents\My Resepte\Beverages.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Voorgeregte & Ander Ligte Eetes", 
                           .Path = "M:\My Documents\My Resepte\Starters.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Hoofgeregte", 
                           .Path = "M:\My Documents\My Resepte\MainDishes.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Watertand Nageregte & Poedings", 
                           .Path = "M:\My Documents\My Resepte\Desserts.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Kraakvars Slaai Resepte", 
                           .Path = "M:\My Documents\My Resepte\Salads.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Souse & Marinades", 
                           .Path = "M:\My Documents\My Resepte\Sauces.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Geurige Tuisgebak", 
                           .Path = "M:\My Documents\My Resepte\Baked.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Gebottelde & Ingelegde Lekerneie", 
                           .Path = "M:\My Documents\My Resepte\Bottled.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Wenke & Boererate vir in en om die Huis", 
                           .Path = "M:\My Documents\My Resepte\Hints.accdb"})
            Return results
        End Function
        End Module
    
    

    Form code

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            CategoryComboBox.DataSource = DatabaseContainer.List()
        End Sub
        Private ActiveDataConn as  OleDbConnection
        Private Sub CategoryComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CategoryComboBox.SelectedIndexChanged
            dim databaseToUse = CType(CategoryComboBox.SelectedItem, DatabaseItem).Path
    
            Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\" & databaseToUse
            'ActiveDataConn = connString
            Using myConn As OleDbConnection = New OleDbConnection(connString)
                myConn.Open()
                Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                TitleListBox.Items.Clear()
                For Each row As DataRow In dtNames.Rows
                    Dim tablename As String = CStr(row(2))
                    TitleListBox.Items.Add(tablename)
                Next
            End Using
        End Sub
    End Class

    Note you may need to add underscores on some lines if you get error as in VS2015 and higher underscores are no longer needed.

    Ending comment: You could use one database rather than the amount you have now if you were to use a proper database design where the databases are replaced with a Category table then in the main table a foreign key used to select items by category id.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, January 21, 2020 8:44 PM
    Moderator

All replies

  • Hello,

    Try this

    Dim cmdText As String = "SELECT * FROM [Main Dishes]"


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, January 20, 2020 8:06 PM
    Moderator
  • Stil geting an error, diferent one this time,

    I checked the DataBase speling of the name, MainDishes no space.

    No change after I corected the speling.

    Monday, January 20, 2020 9:02 PM
  • Well after looking at your code may be you meant

    This

    Dim cmdText As String = "SELECT * FROM " & tableName 

    or (this is for newer versions of VB.NET)

    Dim cmdText As String = $"SELECT * FROM {tableName}"


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, January 20, 2020 9:48 PM
    Moderator
  • Thanks that worked. Atleesed Im moving forwards, allmost there,

    .This is now the next error.  Using Visual Studio 2013


    Tuesday, January 21, 2020 9:47 AM
  • Hello,

    The only thing that would cause this is a table name with spaces so use this.

    Dim cmdText As String = "SELECT * FROM [" & tableName & "]"


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, January 21, 2020 10:32 AM
    Moderator
  • The code is working in the test app, now I am atempting using it in my actual app with is an Virtual Recipe Book in Afrikaans.  

    I made a change at the top of the code, What I am atemting is as follows.  

    I have a CategoryComboBox Is linked via a Select Case statment to 9 DataBases all in the same folder, when a selection in the Combobox is made the Tabels of that selected DataBase will show in TitleListBox.  

    What is needed now is to modify the code Blok "TitleListBox_SelectedIndexChanged" so that when a selection in TitleListBox is made the contence of this ListBox must change to the Recipe Titles in that Tabel that was selected.  

    I Have posted the relivant code to show what I mean.  

    Hope this is posable.  

    Dim ActiveDataConn As String = ""
    
        Private Sub CategoryComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CategoryComboBox.TextChanged
    
            Select Case CategoryComboBox.Text
    
                Case Is = "Smaaklik Tuisgemaakte Drankies"
    
                    Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\Beverages.accdb"
                    ActiveDataConn = connString
                    Using myConn As OleDbConnection = New OleDbConnection(connString)
                        myConn.Open()
                        Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                        TitleListBox.Items.Clear()
                        For Each row As DataRow In dtNames.Rows
                            Dim tablename As String = CStr(row(2))
                            TitleListBox.Items.Add(tablename)
                        Next
                    End Using
    
                Case Is = "Voorgeregte & Ander Ligte Eetes"
    
                    Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\Starters.accdb"
                    ActiveDataConn = connString
                    Using myConn As OleDbConnection = New OleDbConnection(connString)
                        myConn.Open()
                        Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                        TitleListBox.Items.Clear()
                        For Each row As DataRow In dtNames.Rows
                            Dim tablename As String = CStr(row(2))
                            TitleListBox.Items.Add(tablename)
                        Next
                    End Using
    
                Case Is = "Hoofgeregte"
    
                    Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\MainDishes.accdb"
                    ActiveDataConn = connString
                    Using myConn As OleDbConnection = New OleDbConnection(connString)
                        myConn.Open()
                        Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                        TitleListBox.Items.Clear()
                        For Each row As DataRow In dtNames.Rows
                            Dim tablename As String = CStr(row(2))
                            TitleListBox.Items.Add(tablename)
                        Next
                    End Using
    
                Case Is = "Watertand Nageregte & Poedings"
    
                    Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\Desserts.accdb"
                    ActiveDataConn = connString
                    Using myConn As OleDbConnection = New OleDbConnection(connString)
                        myConn.Open()
                        Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                        TitleListBox.Items.Clear()
                        For Each row As DataRow In dtNames.Rows
                            Dim tablename As String = CStr(row(2))
                            TitleListBox.Items.Add(tablename)
                        Next
                    End Using
    
                Case Is = "Kraakvars Slaai Resepte"
    
                    Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\Salads.accdb"
                    ActiveDataConn = connString
                    Using myConn As OleDbConnection = New OleDbConnection(connString)
                        myConn.Open()
                        Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                        TitleListBox.Items.Clear()
                        For Each row As DataRow In dtNames.Rows
                            Dim tablename As String = CStr(row(2))
                            TitleListBox.Items.Add(tablename)
                        Next
                    End Using
    
                Case Is = "Souse & Marinades"
    
                    Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\Sauces.accdb"
                    ActiveDataConn = connString
                    Using myConn As OleDbConnection = New OleDbConnection(connString)
                        myConn.Open()
                        Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                        TitleListBox.Items.Clear()
                        For Each row As DataRow In dtNames.Rows
                            Dim tablename As String = CStr(row(2))
                            TitleListBox.Items.Add(tablename)
                        Next
                    End Using
    
                Case Is = "Geurige Tuisgebak"
    
                    Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\Baked.accdb"
                    ActiveDataConn = connString
                    Using myConn As OleDbConnection = New OleDbConnection(connString)
                        myConn.Open()
                        Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                        TitleListBox.Items.Clear()
                        For Each row As DataRow In dtNames.Rows
                            Dim tablename As String = CStr(row(2))
                            TitleListBox.Items.Add(tablename)
                        Next
                    End Using
    
                Case Is = "Gebottelde & Ingelegde Lekerneie"
    
                    Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\Bottled.accdb"
                    ActiveDataConn = connString
                    Using myConn As OleDbConnection = New OleDbConnection(connString)
                        myConn.Open()
                        Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                        TitleListBox.Items.Clear()
                        For Each row As DataRow In dtNames.Rows
                            Dim tablename As String = CStr(row(2))
                            TitleListBox.Items.Add(tablename)
                        Next
                    End Using
    
                Case Is = "Wenke & Boererate vir in en om die Huis"
    
                    Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\Hints.accdb"
                    ActiveDataConn = connString
                    Using myConn As OleDbConnection = New OleDbConnection(connString)
                        myConn.Open()
                        Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                        TitleListBox.Items.Clear()
                        For Each row As DataRow In dtNames.Rows
                            Dim tablename As String = CStr(row(2))
                            TitleListBox.Items.Add(tablename)
                        Next
                    End Using
    
            End Select
    
        End Sub
    
        Private Sub TitleListBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TitleListBox.SelectedIndexChanged
    
            Dim tableName As String = TitleListBox.SelectedItem.ToString()
            Using myConn As OleDbConnection = New OleDbConnection(ActiveDataConn)
                myConn.Open()
                Dim cmdText As String = "SELECT * FROM [EggDishes]"
    
                Using cmd As OleDbCommand = New OleDbCommand(cmdText, myConn)
                    Dim reader = cmd.ExecuteReader()
                    While reader.Read()
                        TextBox1.Text = reader("ID").ToString()
                        TextBox2.Text = reader("Recipe Name").ToString()
                        TextBox3.Text = reader("Caption").ToString()
                        TextBox4.Text = reader("Delivery").ToString()
                    End While
                End Using
            End Using
    
        End Sub

    Tuesday, January 21, 2020 7:58 PM
  • Suppose we can reduce how many lines of code you have currently to open a database.

    Add this class to your project.

    Public Class DatabaseItem 
        Public Property DisplayName() As  String
        Public Property Path() As String
        Public Overrides Function ToString() As String
            Return DisplayName
        End Function
    End Class

    Add the following module to your project

    Public Module DatabaseContainer
        Public Function List As List(Of DatabaseItem)
            Dim results = new List(Of DatabaseItem)
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Smaaklik Tuisgemaakte Drankies", 
                           .Path = "M:\My Documents\My Resepte\Beverages.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Voorgeregte & Ander Ligte Eetes", 
                           .Path = "M:\My Documents\My Resepte\Starters.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Hoofgeregte", 
                           .Path = "M:\My Documents\My Resepte\MainDishes.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Watertand Nageregte & Poedings", 
                           .Path = "M:\My Documents\My Resepte\Desserts.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Kraakvars Slaai Resepte", 
                           .Path = "M:\My Documents\My Resepte\Salads.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Souse & Marinades", 
                           .Path = "M:\My Documents\My Resepte\Sauces.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Geurige Tuisgebak", 
                           .Path = "M:\My Documents\My Resepte\Baked.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Gebottelde & Ingelegde Lekerneie", 
                           .Path = "M:\My Documents\My Resepte\Bottled.accdb"})
            results.Add(New DatabaseItem() With{
                           .DisplayName = "Wenke & Boererate vir in en om die Huis", 
                           .Path = "M:\My Documents\My Resepte\Hints.accdb"})
            Return results
        End Function
        End Module
    
    

    Form code

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            CategoryComboBox.DataSource = DatabaseContainer.List()
        End Sub
        Private ActiveDataConn as  OleDbConnection
        Private Sub CategoryComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CategoryComboBox.SelectedIndexChanged
            dim databaseToUse = CType(CategoryComboBox.SelectedItem, DatabaseItem).Path
    
            Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\" & databaseToUse
            'ActiveDataConn = connString
            Using myConn As OleDbConnection = New OleDbConnection(connString)
                myConn.Open()
                Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                TitleListBox.Items.Clear()
                For Each row As DataRow In dtNames.Rows
                    Dim tablename As String = CStr(row(2))
                    TitleListBox.Items.Add(tablename)
                Next
            End Using
        End Sub
    End Class

    Note you may need to add underscores on some lines if you get error as in VS2015 and higher underscores are no longer needed.

    Ending comment: You could use one database rather than the amount you have now if you were to use a proper database design where the databases are replaced with a Category table then in the main table a foreign key used to select items by category id.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, January 21, 2020 8:44 PM
    Moderator
  • Thanke for shortening that code.

    What is still needed is a way to make "TitleListBox_SelectedIndexChanged" show Recipe Titles in that same ListBox from the Tabel that was selected in it.   



    Wednesday, January 22, 2020 8:45 AM
  • Since I don't have your setup I can not test the following so it may or may not work.

    Public Class Form2
        Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            TitleListBox.DisplayMember = "TABLE_NAME"
            CategoryComboBox.DataSource = DatabaseContainer.List()
        End Sub
        Private ActiveDataConn As OleDbConnection
        Private Sub CategoryComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) _
            Handles CategoryComboBox.SelectedIndexChanged
    
            Dim databaseToUse = CType(CategoryComboBox.SelectedItem, DatabaseItem).Path
    
            Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=M:\My Documents\My Resepte\" & databaseToUse
            'ActiveDataConn = connString
            TitleListBox.DataSource = Nothing
    
            Using myConn As OleDbConnection = New OleDbConnection(connString)
                myConn.Open()
                Dim dtNames As DataTable = myConn.GetSchema("Tables", New String() {Nothing, Nothing, Nothing, "TABLE"})
                TitleListBox.DataSource = dtNames
                '
                ' Try this as is then if it works try commenting this line out, see if it works
                ' still as it's also set in Form Load
                '
                TitleListBox.DisplayMember = "TABLE_NAME"
    
            End Using
    
        End Sub
    End Class

    Since I don't have a bunch of databases to try this out (as mentioned earlier you could had used a single database for all your databases) here is a mock up and note the connection string came from a method I use to create dynamica connection rather than hard coded connection strings.

    Imports System.Data.OleDb
    
    Public Class TableNamesForm
        Private Sub TableNamesForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim ConnectionString As String =
                    "Provider=Microsoft.ACE.OLEDB.12.0;" &
                    "Data Source=C:\Dotnet_Development\VS2017\" &
                    "MSDN_Access1\BasicReadTable\bin\Debug\Database1.accdb"
    
            Using cn As New OleDbConnection(ConnectionString)
    
                cn.Open()
    
                Dim dtNames As DataTable =
                        cn.GetSchema("Tables", New String() _
                                        {Nothing, Nothing, Nothing, "TABLE"})
    
                TitleListBox.DataSource = dtNames
                TitleListBox.DisplayMember = "TABLE_NAME"
            End Using
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            TitleListBox.DataSource = Nothing
    
            MessageBox.Show("About to change")
    
            Dim ConnectionString As String =
                    "Provider=Microsoft.ACE.OLEDB.12.0;" &
                    "Data Source=C:\Dotnet_Development\VS2017\" &
                    "MSDN_Access1\BasicReadTable\bin\Debug\Database1.accdb"
    
            Using cn As New OleDbConnection(ConnectionString)
    
                cn.Open()
    
                Dim dtNames As DataTable =
                        cn.GetSchema("Tables", New String() _
                                        {Nothing, Nothing, Nothing, "TABLE"})
    
                TitleListBox.DataSource = dtNames
                TitleListBox.DisplayMember = "TABLE_NAME"
            End Using
        End Sub
    End Class

    Button1 Click is a simulation of changing the DataSource to another database (even though I don't have one)

    Imports System.Data.OleDb
    
    Public Class TableNamesForm
        Private Sub TableNamesForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim ConnectionString As String =
                    "Provider=Microsoft.ACE.OLEDB.12.0;" &
                    "Data Source=C:\Dotnet_Development\VS2017\" &
                    "MSDN_Access1\BasicReadTable\bin\Debug\Database1.accdb"
    
            Using cn As New OleDbConnection(ConnectionString)
    
                cn.Open()
    
                Dim dtNames As DataTable =
                        cn.GetSchema("Tables", New String() _
                                        {Nothing, Nothing, Nothing, "TABLE"})
    
                TitleListBox.DataSource = dtNames
                TitleListBox.DisplayMember = "TABLE_NAME"
            End Using
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            TitleListBox.DataSource = Nothing
    
            MessageBox.Show("About to change")
    
            Dim ConnectionString As String =
                    "Provider=Microsoft.ACE.OLEDB.12.0;" &
                    "Data Source=C:\Dotnet_Development\VS2017\" &
                    "MSDN_Access1\BasicReadTable\bin\Debug\Database1.accdb"
    
            Using cn As New OleDbConnection(ConnectionString)
    
                cn.Open()
    
                Dim dtNames As DataTable =
                        cn.GetSchema("Tables", New String() _
                                        {Nothing, Nothing, Nothing, "TABLE"})
    
                TitleListBox.DataSource = dtNames
                TitleListBox.DisplayMember = "TABLE_NAME"
            End Using
        End Sub
    End Class

    Source for the last example is here


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Wednesday, January 22, 2020 1:13 PM
    Moderator
  • Karen is ther a way I can contact you so I can sent you the compleat setap.  

    I just want to cleanup ap a bit and try what you posted here. 

    Wednesday, January 22, 2020 2:02 PM
  • Karen is ther a way I can contact you so I can sent you the compleat setap.  

    I just want to cleanup ap a bit and try what you posted here. 

    The best idea is to create a .zip file (must be a .zip file, not some other form of archive file) of the entire Visual Studio solution including the databases (place the databases in the root folder of the project).

    Then go to Microsoft OneDrive, sign in using the same login as when logging in to these forums. Open Windows Explorer to the folder with the .zip file and drag the .zip file to OneDrive.

    Copy the link in step 4 to a new reply.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, January 22, 2020 2:12 PM
    Moderator
  • Sorry for the dely. For some reson One drive will not log in.  

    I have a Google Drive account that I often use, will that work? I'll stil need a e-mail address from you.

    I gor a werry weard error since I used your code, I;m not saying your code did this, it is just a weard coincadince I think.

    By clicking the ComboBox a little window to the left with the contence that is sepose to apeer below the ComboBox apeers.

    Have you got enu idea what can cause this?  

    Friday, January 24, 2020 9:50 AM
  • Sorry but I don't give out my email address to the public which nobody should do.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, January 24, 2020 11:01 AM
    Moderator
  • How am I going to get the ap to you?
    Friday, January 24, 2020 12:59 PM
  • How am I going to get the ap to you?

    You need to get login to OneDrive. All you need to do is to use the same user name and password on OneDrive that you use here to login or create a new account.

    You can try using your Google drive account, I've never used Google drive so I can help you with that. My guess is Google drive allows you some how to share a link to a .zip file (as I said it must be a .zip file).


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, January 24, 2020 1:06 PM
    Moderator
  • Whether I use OneDrive or GoogleDrive it needs a e mail address to shere.
    Friday, January 24, 2020 1:31 PM
  • Whether I use OneDrive or GoogleDrive it needs a e mail address to shere.

    Why do you need an email address? 

    In the following link anyone can download the zip file from my one drive for example.

    https://1drv.ms/u/s!AtGAgKKpqdWjhF3y7k_CQJogg8XQ?e=mDuNnY


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, January 24, 2020 1:33 PM
    Moderator
  • The link opens fine.  Who receives what I shere there?
    Friday, January 24, 2020 1:53 PM
  • The link opens fine.  Who receives what I shere there?
    The link has nothing to do with your question, it's an example of how to share from OneDrive.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, January 24, 2020 2:04 PM
    Moderator
  • It seems I still need n e mail or Name to shere. I tryde your name it dont seem to work.  

    I tryed this, hope it works.  

    https://onedrive.live.com/?id=A631480BF6B3D338%21106&cid=A631480BF6B3D338

    Friday, January 24, 2020 2:49 PM
  • It seems I still need n e mail or Name to shere. I tryde your name it dont seem to work.  

    I tryed this, hope it works.  

    https://onedrive.live.com/?id=A631480BF6B3D338%21106&cid=A631480BF6B3D338

    It says the file no longer exists.

    When you say 

    It seems I still need n e mail or Name to shere. 

    Don't know what to say, I've been sharing files on OneDrive since 2008 and never needed someone's email address.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, January 24, 2020 3:10 PM
    Moderator
  • This is a link to GoogleDrive

    https://drive.google.com/file/d/19o3WrHwZeyFpAItMJaQ3jpjq_gdqT6Rp/view?usp=sharing

    Friday, January 24, 2020 3:21 PM
  • This is a link to GoogleDrive

    https://drive.google.com/file/d/19o3WrHwZeyFpAItMJaQ3jpjq_gdqT6Rp/view?usp=sharing

    I can get the file but can not open the files as it's not a .zip file, instead its a .7z file which I can not open.

    The two types are not compatible and Windows 10 does not have the ability to open this file.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, January 24, 2020 3:28 PM
    Moderator
  • I'm placeing it un ziped, is it's not big.

    https://drive.google.com/drive/folders/1PTxrX1vwaWbOflm1MYoDPtD__7BWcKyQ?usp=sharing

    Friday, January 24, 2020 3:38 PM
  • I'm placeing it un ziped, is it's not big.

    https://drive.google.com/drive/folders/1PTxrX1vwaWbOflm1MYoDPtD__7BWcKyQ?usp=sharing

    When you have a proper .zip file I will look at this. Remember, I'm not a Microsoft employee here to assist yet finding this increasingly impossible to do so.

    With the current effort I may or may not get a good start and don't have time to do a trial and error here.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, January 24, 2020 3:57 PM
    Moderator
  • https://drive.google.com/file/d/1tcVpEXs-6mMml0_BfaCG9XqLcL4tnQfv/view?usp=sharing

    Please tell me this works.

    Friday, January 24, 2020 5:12 PM
  • https://drive.google.com/file/d/1tcVpEXs-6mMml0_BfaCG9XqLcL4tnQfv/view?usp=sharing

    Please tell me this works.

    Unzip this to a different folder than the current project. I put the databases under the bin folder.

    https://1drv.ms/u/s!AtGAgKKpqdWjkGo8atm0IBU7bsYO?e=xPFyF0


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, January 24, 2020 5:51 PM
    Moderator
  • Thanks for havivg a look.  Did you see that strange litle window when the CombBox is clicked.  

    What line must I change to have the app use the DataBases in My Documents? I just prefer to have the actual Resipes in My Documents.  

    Friday, January 24, 2020 6:16 PM
  • Thanks for havivg a look.  Did you see that strange litle window when the CombBox is clicked.  

    What line must I change to have the app use the DataBases in My Documents? I just prefer to have the actual Resipes in My Documents.  

    Best way to learn is to study the code, I'm rather busy anyways at my day job.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, January 24, 2020 6:39 PM
    Moderator