First, I had to install the mono-version for c#-support.
My test-project throw out a build-error, that the mbuild couldn't find the .Net-Framework, but it was installed.
After installing the whole Visual-Studio-Package or editing the csproj I got the same error.
Before giving up for the day I decided to create a brand new godot-project. This one I could build.
So I created the test project with a moving player.
After that I installe VS-code and there I installed the package manager.
With STRG+P and add package I added Npgsql.
VS-Code added the lines:
to my csproj - File.
Now I run dotnet restore in VS-code.
Now I run nuget restore in VS-Code. Sadly, this didn't worked and I can't figure out, why.
I removed the lines in csproj-files.
Now I try to open a test-database and write a line in a table for test-reasons:
public override void _Ready(){
GD.Print("test");
_screenSize = GetViewport().Size;
string cs = "Host=kandula.db.elephantsql.com;Username=hidden_user;Password=hidden_pw;Database=hidden_db";
con = new NpgsqlConnection(cs);
try
{
con.Open();
NpgsqlCommand cmd = new NpgsqlCommand("INSERT INTO public.cars (name, price) VALUES (@n, @p)", con);
cmd.Parameters.AddWithValue("n", "bla");
cmd.Parameters.AddWithValue("p", 123);
//cmd.Prepare();
cmd.ExecuteNonQuery();
}
catch
{
GD.Print("catch");
return;
}}
First, I don't know why it doesn't work with VS-Studio. Also, I don't know how to handle exceptions in godot.
But: Awesome, it works, the values are in the database. I think I give godot and myself a try and look for some basic tutorials.
Thanks for your help!