-2

My Goal: Add a column to mysql database using visual basic!

I have tried multiple ways, but here is the code I'm currently using:

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
    MysqlConn = New MySqlConnection
    MysqlConn.ConnectionString = "Server=xxx.xx.xxx.xxx;Port=3306;Database=test;Uid=tester;Pwd=***"
    Try
        MysqlConn.Open()
        Dim Query As String
        Query = "ALTER TABLE user ADD test INT NOT NULL"
        COMMAND = New MySqlCommand(Query, MysqlConn)
        MysqlConn.Close()
    Catch ex As Exception
    End Try
End Sub

I think it's a problem with the query! Thanks for your help in advance! This is different from ms sql, it's visual basic.

  • 1
    Possible duplicate of [insert a NOT NULL column to an existing table](https://stackoverflow.com/questions/3492947/insert-a-not-null-column-to-an-existing-table) – kielou Jun 22 '17 at 02:34
  • The link doesn't help me, I have tried everything on the page and nothing is working. I would like an example of the not null column in visual basic. – gamer_central6 Jun 22 '17 at 06:43

1 Answers1

0

My visual studio was actually not using my most up to date code and now everything is working LOL. Here is my revised code:
MysqlConn = New MySqlConnection MysqlConn.ConnectionString = "Server=**.**.***.***;Port=3306;Database=test;Uid=tester;Pwd=***" Dim READER As MySqlDataReader Try MysqlConn.Open() Dim Query As String Query = "alter table test.user add test int not null" COMMAND = New MySqlCommand(Query, MysqlConn) READER = COMMAND.ExecuteReader MysqlConn.Close() Catch ex As Exception End Try