trying to connect mysql with vb.net
- by user225269
I've found this at connection strings.com
http://connectionstrings.com/mysql
Do I need to download connector-net from this site: http://dev.mysql.com/downloads/connector/net/
I recycled the code that I used in connecting vb.net with ms sql:
Imports system.data.sqlclient
idnum = TextBox1.Text
lname = TextBox2.Text
fname = TextBox3.Text
skul = TextBox4.Text
Using sqlcon As New SqlConnection("Server=localhost;Port=3306;Database=testing;Uid=root;Pwd=nitoryolai123$%^;")
sqlcon.Open()
Dim sqlcom As New SqlCommand()
sqlcom.Connection = sqlcon
sqlcom.CommandText = "INSERT INTO [student](ID, LASTNAME, FIRSTNAME, SCHOOL) VALUES (@ParameterID, @ParameterLastName, @ParameterFirstName, @ParameterSchool)"
sqlcom.Parameters.AddWithValue("@ParameterID", TextBox1.Text)
sqlcom.Parameters.AddWithValue("@ParameterLastName", TextBox2.Text)
sqlcom.Parameters.AddWithValue("@ParameterFirstName", TextBox3.Text)
sqlcom.Parameters.AddWithValue("@ParameterSchool", TextBox4.Text)
sqlcom.ExecuteNonQuery()
End Using
But I get this error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Please help, what solutions would you recommend to this problem?