
CONECTAR MYSQL Y REALIZAR PRIMERAS SENTENCIAS DE MYSQL
Publicado por OHC (5 intervenciones) el 07/10/2015 17:21:15
Buenos días a todos , su apoyo para saber como abrir la conexión de c# y mysql para empezar a realizar consulta de antemano se los agradeceria si me apoyan con este tema.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public string cnx;
public Form1()
{
InitializeComponent();
}
private void iniciarconexion()
{
try
{
MySqlConnection conexion = new MySqlConnection();
conexion.ConnectionString = "Server=xx.xx.xx.xx;Database=xxxxxx; Uid=xxxxxx;Pwd=xxxxxx;";
conexion.Open();
MessageBox.Show("Conexion con exito");
}
catch (MySqlException)
{
MessageBox.Show("Ocurrio un error al intentar conectarse");
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
//COMO PUEDO MANDAR A LLARMAR EL METODO iniciarconexion() PARA ABRIR LA CONEXION Y EMPESAR A REALIZAR CONSULTAS
CON MYSQL
//????????
//Realizamos una selecion de la tabla usuarios.
string sql = "SELECT * FROM catclientes";
MySqlCommand cmd = new MySqlCommand(sql, COMO ABRIRI LA CONEXION );
}
}
}
Valora esta pregunta


0