Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 display in datagrid

Author  Topic 

appandai
Starting Member

3 Posts

Posted - 2012-11-20 : 10:42:21
please help me to solve the problem, i am not getting any display in the datagrid

{
string strCon = "Data Source=HP-PC\\SQLEXPRESS;Initial Catalog=C:\\PROGRAM FILES\\MICROSOFT SQL SERVER\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\STUDENT.MDF;Integrated Security=True;Pooling=False";

string strSQL = "SELECT * from [C:\\PROGRAM FILES\\MICROSOFT SQL SERVER\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\STUDENT.MDF].dbo.Complaint";


SqlDataAdapter dataAdapter = new SqlDataAdapter(strSQL, strCon);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);

DataTable table = new DataTable("Complaint");

dataAdapter.Fill(table);
dataGrid1.ItemsSource = table.DefaultView;


}



sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-11-20 : 11:50:23
It may be throwing an exception and silently going away and displaying your window. Wrap the code in a try-catch block and write the exceptions if any to debug trace or a popup window.

Also, you may want to start with an example somewhere (here is one: http://www.dotnetperls.com/sqldataadapter), get that to work, and make incremental changes to the code to get to where you want to.
Go to Top of Page
   

- Advertisement -