Skip to content

Instantly share code, notes, and snippets.

/gist:bbf8688d1c5eb1e53fb1 Secret
Created Mar 19, 2015

Embed
What would you like to do?
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 Time_Sheet
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
Fillcombo();
}
void Fillcombo()
{
string constring = "datasource=localhost;port=3306;username=root;password=root";
string Query = "select * from timesheet.activities ;";
MySqlConnection conDataBase = new MySqlConnection(constring);
MySqlCommand cmdDataBase = new MySqlCommand(Query, conDataBase);
MySqlDataReader myReader;
try
{
conDataBase.Open();
myReader = cmdDataBase.ExecuteReader();
while (myReader.Read())
{
string sActivity = myReader.GetString("activity");
activity_box.Items.Add(sActivity);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.