-2

I'm in C# language and still learning about Model View Control. Now I have project for my school to make a cashier application, but I have this error when I'm trying to connect mysql database.

The error is :

An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll

Additional information: Keyword not supported: 'port'.

this is my codes :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;

namespace AppKasir.KoneksiDB
{
    class KoneksiBarang
    {
        public static SqlConnection getKoneksiBarang()
        {
            string strCon = "SERVER = localhost; PORT = 3306; UID = root; PWD = ; Database = db_kasirmysql;";
            return new SqlConnection(strCon);
        }
    }
}

The error is at line:

return new SqlConnection(strCon);

Which the symbol ; is underline red.

2
  • Can you remove subsring PORT = 3306;. Port number 3306 is default for mysql and there is no need to specify it. If you remove it - error Is there anyway? Commented Dec 17, 2017 at 12:18
  • @AntonGorbunov yea there is, the error now from dataGridViewBarang.DataMember = "barangkasir"; - An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll Additional information: Child list for field barangkasir cannot be created. Commented Dec 17, 2017 at 12:31

1 Answer 1

0

System.Data.SqlClient.SqlConnection represents an open connection to a SQL Server database.

Try this if you want to access a MySQL database:
How to connect to MySQL Database?

Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your answer, it's helpful and can fix my problem, sorry for long reply

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.