SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 display in datagrid
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

appandai
Starting Member

India
3 Posts

Posted - 11/20/2012 :  10:42:21  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/20/2012 :  11:50:23  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000