Hello everyone,
I've a problem with a MySQL database and filling the dataset, the database is running local on XAMPP.
this is my Class where I set the properties.
this is my Form.cs CodeCode:namespace SQLDatabaseApp { 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); MySqlDataAdapter Adapter = new MySqlDataAdapter(); DataSet ds = new DataSet(); Connection.Open(); Adapter.SelectCommand = Command; Adapter.Fill(ds); } } }
If i try to run this code is selects the line: "Adapter.Fill(ds);" and report the following errorCode:namespace SQLDatabaseApp { public partial class Form1 : Form { DBSettings settings = new DBSettings(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { settings.BasicSettings(dgvViewDatabase); } } }
Fill: SelectCommand.Connection property has not been initialized.
Does somebody knows what I am doing wrong?
thank you for your support.
Greetings
Jelte.



LinkBack URL
About LinkBacks



