MySQL Connection to Visual Studio .Net

preview_player
Показать описание
The tutorial shows how to connect MySQL to VB.Net. Below is the major code that i used.

Dim myconn As New MySqlConnection(-server=localhost;user id=root; password=locked; database=user-) 'this is supposed to be a Public declaration as in the program
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim cmd As New MySqlCommand

If TextBox1.Text = -- Or TextBox2.Text = -- Or TextBox3.Text = -- Or TextBox4.Text = -- Or TextBox5.Text = -- Then
MsgBox(-Provide all details!-)
Else
Try
myconn.Open()
cmd.Connection = myconn
cmd.CommandText = -insert into person (firstname,surname,username,password) values ('- & TextBox1.Text & -','- & TextBox2.Text & -','- & TextBox3.Text & -','- & TextBox4.Text & -')-
cmd.ExecuteNonQuery()
MsgBox(-SAVED-)
TextBox1.Text = --
TextBox2.Text = --
TextBox3.Text = --
TextBox4.Text = --
TextBox5.Text = --
myconn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Sub
Рекомендации по теме
Комментарии
Автор

Good work Huey. Mabatsira sitereki mudhara.

lionking.MuZimba
Автор

I don't know if I got you right but from what I understand, you have added a new column in your app and you want to do the same to the database, to do that you will have to use the ALTER TABLE tablename ADD columname VARCHAR (20) if the column will be a varchar column.

HueyMataruse
Автор

does it have the same codes and connection string for visual studio professional 2013?

jm.mirabueno
Автор

hi..we've been using the same visual studio and mysql database..but now i'm having trouble viewing my existing database.I've added a new table column in my application now i need to know how i could add the same column to my database or view my existing database.can u help me pls?

crizzy
Автор

what is the code to view the data in MySql using visual basic?

dhrdv
Автор

dhrdv23, can you clear specify your question for example as in are you referring to Visual Basic as in VB6 or otherwise + how do you want to view the data from the database as in Datagrid view or combobox etc.

HueyMataruse
Автор

You don't show how to connect to mySQL... just install the tools.... I spent my time here for nothing.

alcidesfmelof
visit shbcf.ru