How to create a table for Access database in the VB.net vs2019

Mansour_Dalir 2,036 Reputation points
2023-07-13T10:54:02.6833333+00:00

hi .

        Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=MyPath.accdb;"
        Using connection As New OleDbConnection(connectionString)
            Try
            connection.Open()
             dim SqlCreator as string="Create Table Table1" & vbNewLine &
             "Column1 Text(50)"
             ' What should I do to create the table?
            Catch ex As OleDbException
               
            Finally
                connection.Close()
            End Try
      End Using
Developer technologies VB
0 comments No comments
{count} votes

Accepted answer
  1. Olaf Helper 47,436 Reputation points
    2023-07-13T11:06:59.8566667+00:00

    dim SqlCreator as string="Create Table Table1" & vbNewLine & "Column1 Text(50)" ' What should I do to create the table?

    Use an OleDbCommand to execute a SQL statement

    https://learn.microsoft.com/en-us/dotnet/api/system.data.oledb.oledbcommand?view=dotnet-plat-ext-7.0

    and moreover, use the correct SQL syntax to create a table:

    https://www.w3schools.com/sql/sql_create_table.asp

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.