none
Make a table appear in the data sources window using ado.net RRS feed

  • Question

  • Hello,

    I want to create a table in the data sources window using ado.net.

    If it is possible, then can anyone provide me the steps?

            ConnX = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\NamesDatabase.mdb")
            da = New OleDbDataAdapter("CREATE TABLE EmailAddresses(EmailID int NOT NULL,
                        Name Email(50) NULL,
                        ID int FOREIGN KEY REFERENCES tblNames(ID)", ConnX) 'Create the DataAdapter.
    
            Dim ds As DataSet = New DataSet("EmailAddresses") 'Fill the DataSet with data.
            Dim dt As DataTable = New DataTable("EmailAddresses")
    
            Dim DataGridView1 As New DataGridView()
            Dim BindingSource1 As New BindingSource()
    
    
            Dim column1 As New DataGridViewTextBoxColumn()
            Dim column2 As New DataGridViewTextBoxColumn()
            Dim column3 As New DataGridViewTextBoxColumn()
    
    
    
            column1.DataPropertyName = "EmailID"
            column1.Name = "EmailID"
            DataGridView1.Columns.Add(column1)
            DataGridView1.Item(0, 0).Value = "1"
    
    
            column2.DataPropertyName = "Name"
            column2.Name = "Name"
            DataGridView1.Columns.Add(column2)
            DataGridView1.Item(1, 0).Value = ""
    
            column3.DataPropertyName = "ID"
            column3.Name = "ID"
            DataGridView1.Columns.Add(column3)
            DataGridView1.Item(2, 0).Value = "1"
    
    
    
    
            With DataGridView1
                .Height = 1000
                .Top = 500
                .Left = 500
                .Width = 1000
            End With
    
    
            column1.Visible = True
            column2.Visible = True
            column3.Visible = True
    
            ' Initialize the form.
            Me.Controls.Add(DataGridView1)
            Me.AutoSize = True
    
        End Sub

    Here is the screenshot:

    What I want to perform is to create a table in the data sources window.  Here is the current table:

    All users are welcome to assist me in this task.

    Regards,

    JohnDBCTX


    jp

    Saturday, January 18, 2020 10:02 PM

Answers

  • Hi,

    As far as I know, visual studio provides this method to add a database table or other object to an existing dataset.

    As for the results you want to achieve using ado.net, you can adopt Karen's reply.

    Hope it be helpful.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by JohnDBCTX Tuesday, January 21, 2020 12:58 AM
    Sunday, January 19, 2020 7:46 AM
    Moderator

All replies

  • The Data Source window is for selecting a database for a specific project, not to create a database in the Data Source window.

    If you were dealing with SQL-Server (which I know you are not) you can create a in a .txt file in the project by renaming the text file e.g. TextFile1.txt to TextFile1.sql then write and execute SQL commands but not for MS-Access.

    Now for MS-Access you can create a new database via ADOX then use plain SQL to create and populate tables but need to resort to ADOX for setting up relationships (if you had too).

    So what you are asking for, to create a MS-Access in the Data Source window is not possible.


    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

    Saturday, January 18, 2020 11:30 PM
    Moderator
  • So change the imports to ADOX; from there it would work. correct?

    Regards,

    JohnDBCTX


    jp

    Sunday, January 19, 2020 12:10 AM
  • So change the imports to ADOX; from there it would work. correct?

    Regards,

    JohnDBCTX


    jp

    Read carefully my last sentence in my last 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

    Sunday, January 19, 2020 1:30 AM
    Moderator
  • Hi,

    As far as I know, visual studio provides this method to add a database table or other object to an existing dataset.

    As for the results you want to achieve using ado.net, you can adopt Karen's reply.

    Hope it be helpful.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by JohnDBCTX Tuesday, January 21, 2020 12:58 AM
    Sunday, January 19, 2020 7:46 AM
    Moderator