public partial class Form2 : Form { private TableLogOnInfo infoEntrada = new TableLogOnInfo(); public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { confInfoEntrada(); CrystalReport1 listaReportes = new CrystalReport1(); ReportDocument docReporte = new ReportDocument(); MySqlConnectionStringBuilder connBuilder = new MySqlConnectionStringBuilder(); connBuilder.Add("DataBase", "DataBase"); connBuilder.Add("Data Source", "ipwithdatabasemysql"); connBuilder.Add("User Id", "user"); connBuilder.Add("Password", "pwd"); MySqlConnection connection = new MySqlConnection(connBuilder.ConnectionString); docReporte.Load(@"C:\addresstowhere its located\CrystalReport1.rpt"); DataTable tablaDatos = new DataTable(); try { string cadComando = " "; cadComando = "SELECT * FROM table"; connection.Open(); MySqlDataAdapter adapDatos = new MySqlDataAdapter(cadComando, connection); tablaDatos.Clear(); adapDatos.Fill(tablaDatos); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { connection.Close(); } listaReportes.Database.Tables[0].SetDataSource(tablaDatos); crystalReportViewer1.ReportSource = docReporte; crystalReportViewer1.Zoom(1); } private void confInfoEntrada() { try { infoEntrada.ConnectionInfo.ServerName = "ipwithserver"; infoEntrada.ConnectionInfo.UserID = "User"; infoEntrada.ConnectionInfo.Password = "pwd"; infoEntrada.ConnectionInfo.DatabaseName = "database"; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)