I am trying to display data in my C # windows projects in a datagrid view
I am I keep this error.
"Fill: Select Command. The property of the connection has not been started"
There is nothing wrong with that I am doing this here:
Private Zero form1_load (object sender, event case e) {try {SqlCommand db = new SqlCommand ("select * from Tbls"); SqlDataAdapter sda = New SqlDataAdapter (); Sda.SelectCommand = db; DataTable dbdataset = new datatile (); Sda.Fill (dbdataset); Binding source bsource = new binding resource (); Bsource.DataSource = dbdataset; DataGridView1.DataSource = bsource; Sda.Update (dbdataset); } Hold (Exception pre) {Message Box. Show (ex.Message); }}
You must assign a SqlConnection
object Your SqlCommand
object.
db.Connection = conn;
Where conn
is your SqlConnection
object.
Launch your SqlConnection
object such as:
var conn = new SqlConnection (/ * connection string * /);
Comments
Post a Comment