Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using MySql.Data.MySqlClient;
- namespace Exercicio1
- {
- public partial class Form1 : Form
- {
- MySqlConnection cnn = new MySqlConnection();
- MySqlCommand cmd = new MySqlCommand();
- MySqlDataReader dr;
- public Form1()
- {
- InitializeComponent();
- }
- private void label2_Click(object sender, EventArgs e)
- {
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- cnn.ConnectionString = "server = localhost; user id=root;password=usbw;database=exercicio1;port=3307";
- cnn.Open();
- cmd.CommandText = "select * from aluno";
- cmd.Connection = cnn;
- //cmd = new MysqlCommand("select * from aluno", cnn);
- dr = cmd.ExecuteReader();
- dr.Read();
- textBox1.Text = dr[0].ToString();
- textBox2.Text = dr[1].ToString();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- dr.Read();
- textBox1.Text = dr[0].ToString();
- textBox2.Text = dr[1].ToString();
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement