trying to connect mysql with vb.net

Posted by user225269 on Stack Overflow See other posts from Stack Overflow or by user225269
Published on 2010-03-14T00:50:18Z Indexed on 2010/03/14 0:55 UTC
Read the original article Hit count: 411

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about mysql