0

hey,,

i created one application in asp.net in vc# wich required the results of a stored procedure to be displayed into a datagridview.heres d code..,,

SqlConnection mysql = new SqlConnection(@"Integrated Security=SSPI;Data Source=MANU\SQLEXPRESS;Initial Catalog=info;");
mysql.Open();

SqlCommand searchcmd = new SqlCommand("search", mysql);
searchcmd.CommandType = CommandType.StoredProcedure;
searchcmd.Parameters.Add(new SqlParameter("@sname", SqlDbType.VarChar, 20));
searchcmd.Parameters["@sname"].Value = textBox1.Text.ToString();

SqlDataAdapter da = new SqlDataAdapter(searchcmd);
DataSet ds = new DataSet();
da.Fill(ds);
searchcmd.ExecuteNonQuery();

dataGridView1.DataSource = ds;
dataGridView1.DataMember = "addressbook"

mysql.Close();

and when i run thiss..i get the followin error..

"Child list for field addressbook cannot be created"

can ne1 help me with this...!!!!!

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by mVmagic
0

okay..,, i figured out the solution..!!!

well...the problem was that the table doesnt retain its original name once it is in dataset..!! this is the solution..

dataGridView1.DataMember = ds.Tables[0].TableName;

cheers ~

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.