strawhatgoofy
strawhatgoofy
CC#
Created by strawhatgoofy on 1/31/2023 in #help
Asp.net MVC adding new controller issue
im trying to make a mvc app and wanted to make a controller but it wants me to add a data context type i tried looking it up and it seems i need to use "ApplicationDbContext" from my Data folder but i dont have a data folder or ApplicationDbContext. I also tried to use the default context that it provided and that didnt work either.
7 replies
CC#
Created by strawhatgoofy on 1/29/2023 in #help
❔ MySQL publishing question
I'm working on a habit tracker using c# and mysql and i was about to publish it and send it off to github but i realized it has my MySQLWorkbench database password in it. I know its not a big deal since no one can get access to database but its a password that i use often. is there a way to hide the password and still have the connection still work?
11 replies
CC#
Created by strawhatgoofy on 1/25/2023 in #help
❔ My first time using mySql workbench with c#
im trying to connect mysql to my HabitTrackerand i keep getting "Unable to connect to any of the specified MySql hosts." in the console. Not 100% on what im doing
static void Main(string[] args)
{
MySql.Data.MySqlClient.MySqlConnection conn;
string connectionString = @"Data Source=HabitTracker.db";

try
{
conn = new MySql.Data.MySqlClient.MySqlConnection();
conn.ConnectionString = connectionString;
conn.Open();
var tableCmd = conn.CreateCommand();

tableCmd.CommandText =
@"CREATE TABLE IF NOT EXISTS drinking_water(
Id Integer PRIMARY KEY AUTOINCREMENT,
Date_Of DATE,
Quantity INTEGER
)";
tableCmd.ExecuteNonQuery();
conn.Close();
}
catch(MySql.Data.MySqlClient.MySqlException ex)
{
Console.WriteLine(ex.Message);
}
}
static void Main(string[] args)
{
MySql.Data.MySqlClient.MySqlConnection conn;
string connectionString = @"Data Source=HabitTracker.db";

try
{
conn = new MySql.Data.MySqlClient.MySqlConnection();
conn.ConnectionString = connectionString;
conn.Open();
var tableCmd = conn.CreateCommand();

tableCmd.CommandText =
@"CREATE TABLE IF NOT EXISTS drinking_water(
Id Integer PRIMARY KEY AUTOINCREMENT,
Date_Of DATE,
Quantity INTEGER
)";
tableCmd.ExecuteNonQuery();
conn.Close();
}
catch(MySql.Data.MySqlClient.MySqlException ex)
{
Console.WriteLine(ex.Message);
}
}
9 replies