|
-
August 31st, 2008, 10:55 AM
#1
problem with dataGridViewand XML
data not displayed in dataGridView but when i replace dataGridView by dataGrid it work ...why?
Code:
SqlConnection sqlCon = new SqlConnection();
SqlCommand sqlCmd = new SqlCommand();
sqlCon.ConnectionString=@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\Administrator\My Documents\ContactsDataBase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
sqlCmd.CommandText = "SELECT CustomerID,CustomerName FROM Customers FOR xml auto";
sqlCmd.Connection = sqlCon;
try
{
sqlCon.Open();
XmlReader xmlReader = sqlCmd.ExecuteXmlReader();
DataSet ds = new DataSet();
ds.ReadXml(xmlReader, XmlReadMode.InferSchema);
dataGridView1.DataSource = ds;
}
catch (SqlException)
{
MessageBox.Show("Error Occur");
}
finally
{
sqlCon.Close();
}.
-
September 2nd, 2008, 03:54 PM
#2
Re: problem with dataGridViewand XML
Do you want to Display this in a Gridview(ASP.NET) or Win App?
if you want to Display this in the ASP.NET or Win App you do the Gridview you need to Supply a Datamember "Name of the Datatable". And if this is a Web App you need to call the DataBind method to Bind the Grid to the Page
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|