Unknown database 'sample'
I do not believe it has to do with my code i just think it has to do with mysql workbench. I am not sure if my server for mysql is running. But when I check test connection it tell me that its ok and i don't get errors. I also ran the MySQL Server Instance Config Wizard and i got no problems for it. Here is my code:
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
namespace Connect_to_MySQL_Database
{
class Program
{
static void Main(string[] args)
{
string config = "Server=localhost;Port=3306;Database=sample;Uid=root;password=root;";
MySqlConnection con = new MySqlConnection(config);
MySqlCommand command = con.CreateCommand();
Console.Write("Hello World");
command.CommandText = "Insert into user (username,password) values('felice','roller')";
con.Open();
command.ExecuteNonQuery();
con.Close();
}
}
}

New Topic/Question
Reply




MultiQuote



|