-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.

  • 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? – Anton Gorbunov Dec 17 '17 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. – Ridho Vemby Pradana Dec 17 '17 at 12:31

1 Answers1

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?

skyoxZ
  • 362
  • 1
  • 3
  • 10