Syg kode
MySqlConnection cnnVideos = new MySqlConnection("Database=videos;Data Source=localhost;User Id=root;Password=test");cnnVideos.Open();
string strVideos = "SELECT name, adress from member;";
MySqlCommand cmdVideos = new MySqlCommand(strVideos, cnnVideos);
MySqlDataAdapter dadVideoCollection = new MySqlDataAdapter(cmdVideos);
DataSet setVideos = new DataSet("videos");
dadVideoCollection.Fill(setVideos);
dataGrid1.DataSource = setVideos;
dataGrid1.DataMember = setVideos.Tables[0].TableName;
DataColumn colSecond = setVideos.Tables[0].Columns[1];
MessageBox.Show("The name of the second column is " + colSecond.ColumnName);
cnnVideos.Close();
---
får fejlen System.NullReferenceException: Object reference not set to an instance of an object. - vist på liien med dataGrid1.DataSource = setVideos; ...
Skulle bare gerne have vist data fra databasen i et datagrid men det vil bare ikke :(
