Oke I think I fixed the initialization problem. but if I run the program, no errors or something else shows up, only the Datagridview stays empty. XAMPP is runing and there is no firewall or something like it that blocks the program.
this is my code:
Code:
namespace DBSQLApp
{
class DBSettings
{
public void BasicSettings(DataGridView grid)
{
string strConnectionstring = "Data Source=localhost;" + "Initial Catalog=reisbureau;" + "username=root;password=''";
string strCommandtext = "SELECT * FROM klanten";
MySqlConnection Connection = new MySqlConnection(strConnectionstring);
MySqlCommand Command = new MySqlCommand(strCommandtext,Connection);
MySqlDataAdapter Adapter = new MySqlDataAdapter();
DataSet ds = new DataSet();
Connection.Open();
Adapter.SelectCommand = Command;
Adapter.Fill(ds,"klanten");
grid.DataSource = ds;
}
Form.cs Code:
Code:
namespace DBSQLApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
DBSettings settings = new DBSettings();
public void Form1_Load(object sender, EventArgs e)
{
settings.BasicSettings(Gridview);
}
}
}
everyone Thank you for your Help.
Greetings
Jelte.
Edit:
Thanks for all your help people, I fixed the problem:
the Solution was.
Grid.Datasource = ds.Tables[0];