Skip to content

Instantly share code, notes, and snippets.

Created March 19, 2015 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/bbf8688d1c5eb1e53fb1 to your computer and use it in GitHub Desktop.
Save anonymous/bbf8688d1c5eb1e53fb1 to your computer and use it in GitHub Desktop.
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