mahmud_uk

mahmud_uk

  • NA
  • 48
  • 0

Fill DataGrid using SQL + C#

Jul 22 2004 9:20 AM
Hi i'm trying to fill my datagrid with databse field which i retrived using SQl, but its not functioning. Can anyone look at it and see where it went wrong. Thanks private void Form2_Load(object sender, System.EventArgs e) { SqlConnection da = new SqlConnection( @"Data Source= xxx.xxx.xxx.xxx;"+ "Initial Catalog = drmTest;" + "Network Library=DBMSSOCN;"+ "user id =xxxxxx;"+ "Password=xxxxxx"); da.Open(); SqlCommand thisCommand = da.CreateCommand(); thisCommand.CommandText = "SELECT * FROM License"; Object countResult = thisCommand.ExecuteScalar(); DataSet ds = new DataSet(); da.Fill(ds, "License"); dataGrid1.DataSource = ds.Tables["License"].DefaultView ; da.Close(); }

Answers (5)