1

i established a basic connection to a MySql Database following this https://learn.microsoft.com/en-us/windows/uwp/data-access/mysql-databases

    public MainPage()
    {


        this.InitializeComponent();

        var dt = new DataTable();
        using (var con = new MySqlConnection(
            "User ID = root; Password = ****; Initial Catalog = ****; Server = localhost"))
        using (var cmd = new MySqlCommand("SELECT * FROM ****", con))
        {
            con.Open();
            dt.Load(cmd.ExecuteReader());
        }

        this.DataContext = dt;

    }

now im trying to show the database content into a datagrid and trying to find more related.

1 Answer 1

1

Use a sql data adapter. edit: you can map columns if needed.

    using (con)
    {
        con.Open();
        using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
        {
            sda.Fill(dt);
        }
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.