Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Data;
- using MySql.Data.MySqlClient;
- namespace SistemasDeRegalos.Conexion
- {
- public class coon
- {
- string cadena_conexion()
- {
- string cadena_funcion = "Server=127.0.0.1; Port=3306; Database=conquercol; Uid=root; Password=;";//
- return cadena_funcion;
- }
- // public DataSet dat = new DataSet();
- public DataTable SELECCIONAR(string sql)
- {
- MySqlConnection sqlcon = new MySqlConnection(cadena_conexion());
- MySqlCommand sqlcom1 = new MySqlCommand(sql, sqlcon);
- MySqlDataAdapter datos = new MySqlDataAdapter(sqlcom1);
- DataTable tabla = new DataTable();
- try
- {
- sqlcon.Open();
- datos.Fill(tabla);
- sqlcon.Close();
- sqlcom1.Dispose();
- return tabla;
- }
- catch (Exception axc)
- {
- sqlcon.Close();
- sqlcom1.Dispose();
- return null;
- }
- }
- public string insertar1(string sql)
- {
- MySqlConnection sqlcon = new MySqlConnection(cadena_conexion());
- MySqlCommand sqlcom2 = new MySqlCommand(sql, sqlcon);
- string rta = "NO";
- try
- {
- sqlcon.Open();
- int filas = sqlcom2.ExecuteNonQuery();
- sqlcon.Close();
- if (filas > 0)
- {
- rta = "SI";
- }
- return rta;
- }
- catch (Exception axc)
- {
- return axc.Message.ToString();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement