1
Reply

Fill data from database to DataGridView

hoi lam gi

hoi lam gi

Mar 2 2009 9:04 AM
3.2k
Creat a form and a button on form.The name of button is "FILL".When you click on "FILL" the data form database "Northwind" is filled on dataGridview. can you fix help me? thanks! The code of event when click button: [code] private void button1_Click(object sender, EventArgs e) { string ConnectionString = "Data Source = SUPERCOMPUTER" + "Integrated Security=SSPI" + "Initial Catalog=NorthwindDataSet"; SqlConnection connect = new SqlConnection(); connect.ConnectionString = ConnectionString; string strSql = "SELECT CustomerID,ContactName,ContactTitle FROM Customers"; SqlDataAdapter dad = new SqlDataAdapter(strSql, connect); DataSet dat = new DataSet("Customers"); dad.Fill(dat,"Customers"); customersTableAdapter.Fill(northwindDataSet.Customers); [/code] }

Answers (1)