.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

"childlist for the field A cannot be created" --error for below code..

Posted By: Jayakumar     Posted Date: March 04, 2010    Points:2   Category :Windows Application
hi,

in my windows application (form1.cs), i am having this code under Buuton1_click event.
i am using 3.5,c#.


String connStr = "Data Source=HOME\\SQLEXPRESS;Initial Catalog=DB;Persist Security Info=True;User ID=sa;Password=sa";

String sql = "Select SongId, SongTitle, FilmTitle from A";
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
SqlCommand com = new SqlCommand(sql, conn);
SqlDataAdapter da = new SqlDataAdapter(com);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "A";
conn.Close();


getting error like "childlist for the field A cannot be created"

how to solve this...

jai

Responses
Author: Faizal          Accepted Answer   
Posted Date: March 04, 2010     Points: 10   

Hi,

2 ways you can solve this problem.

1st way) dont set the DataMember property only DataSource (ds.Tables[0]) property is enough

for eg

dataGridView1.DataSource = ds.Tables[0];



or

2nd way) : while filling the DataSet use the aliases A for eg.

da.Fill(ds,"A");
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "A";




Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend