Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Gómez-Gilber-Importar Datos Desde Un Archivo .CSV Hasta La Base de Datos
Gómez-Gilber-Importar Datos Desde Un Archivo .CSV Hasta La Base de Datos
2019-2854
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CargaDatosCsv
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Gilber Gómez Familia
2019-2854
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
namespace CargaDatosCsv
{
public class SQLCONNEXION
{
public static bool Conexion(DataTable data)
{
string cadena = "Data Source=GILBER-PC\\SQLEXPRESS;Initial
Catalog=CargaDatosCSV; Integrated Security=True";
try
{
connection.Open();
connection.Close();
return true;
}
catch (Exception)
{
return false;
throw;
}
}
}
Gilber Gómez Familia
2019-2854
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 System.IO;
namespace CargaDatosCsv
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
v_tabla.Columns.Add("ARTICULO");
v_tabla.Columns.Add("CANTIDAD");
v_tabla.Columns.Add("PRECIO");
}
}
}
Gilber Gómez Familia
2019-2854
bool respuesta = SQLCONNEXION.Conexion(v_tabla);
if (respuesta)
{
MessageBox.Show("Los datos fueron insertados!");
}
else
{
MessageBox.Show("No se pudo completar el proceso!");
}
}
}