Click here to Skip to main content
16,015,594 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to build a sql database username and password for my c# project but when I try to run it, it says
An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll
here is my code
MySqlConnection con = new MySqlConnection(@"Data Source =localhost;port3306;Inital Catalog=id412964_loginl33t;User Id=root;password= ''");

it says the ; is not support but it worked on the tutorial for the video.

What I have tried:

I have tried to take away the ; but it gives me a error so I require the ;
Posted
Updated 9-Apr-17 1:33am
Comments
[no name] 8-Apr-17 19:43pm    
Go read the documentation for whatever the MySqlConnection class is and/or ask whomever wrote it.
Dave Kreskowiak 8-Apr-17 22:14pm    
That one line of code you posted is where the exception is being thrown, it means your connection string is incorrect somehow.

1 solution

Looks like there is a typo in port property, it should be port3306
C#
Port=3306

You can check the below link for readymade connections strings:
MySQL connection strings - ConnectionStrings.com[^]
 
Share this answer
 
Comments
Karthik_Mahalingam 9-Apr-17 23:25pm    
5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900