Passing variable values in ASP.NET and Mysql

Asked

Viewed 124 times

-1

Hello, I’m developing a page in Asp.net and I’m having trouble passing values from a Mysql SELECT to variables. I don’t know where to start and would appreciate examples of how to do.

2 answers

0

this question is almost a How To, so there goes a link to be based, as we have no way to know the depth of your knowledge, I leave this how to basic:

Connecting C# to Mysql

I also suggest you try to learn Entity Framework!

  • Maurício, I was developing in php, however, I was a while without developing and now to make a system for my work I feel the need to use Asp.net. Thanks for the link.

  • Check out @Thiagopires ! I’ve been a developer for a long time. NET and I keep learning things to this day! We can always help those in need and always learn from others! Good learning and welcome to the world . NET! If you are starting I suggest you learn MVC . NET is very good, along with LINQ to Entities!

0


            MySqlConnection con = new MySqlConnection("caminho da base de dados");
            MySqlCommand cmd = new MySqlCommand();
            cmd.Connection = con;
            con.Open();
            cmd.CommandType = CommandType.Text;
            string fu = "SELECT* FROM Tb_Banco where id=2";
            cmd.CommandText = fu;
            MySqlDataReader R;
            R = cmd.ExecuteReader();
            R.Read();

            string Conta_Banco = R["Conta"].ToString();
            string Nome_Banco = R["Banco"].ToString();
  • Thank you for the answer, that answered my question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.