473,383 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

DBGrid does not show the content

Hi,

I write some code to retrieve information from Database.
After I bind the DBGrid it shows the result somehow like a link to the
Table.
When I click on the Table link it displays the whole content. It probably
has
to do with parent-child relationship, but I only have one result set.
Here is the code that accesses Northwind database:

SqlConnection conn = new SqlConnection("data source=YOUR-136F2019DC;initial
catalog=Northwind;password=mypassword;persist security info=True;user
id=sa;workstation id=YOUR-136F2019DC;packet size=4096");

conn.Open();

SqlCommand cmd1 = conn.CreateCommand();

cmd1.CommandText = "Select top 100 * from Customers";

cmd1.CommandType = CommandType.Text;

SqlCommand cmdCust = conn.CreateCommand();

cmdCust.CommandText = "Select top 100 * from Customers";

cmdCust.CommandType = CommandType.Text;

SqlDataAdapter daCust = new SqlDataAdapter(cmdCust);

DataSet dsCust = new DataSet();

daCust.Fill(dsCust);

dgCust.DataSource = dsCust;

dgCust.Expand(-1);

conn.Close();

It's probably some setting I am not aware of.

Thanks,

Doru
Jan 27 '06 #1
4 1738
Why are you using 2 command to call the same SQL? (Hope you are not Filling
the DataSet twice on a child table?)
But that should not affect the datagrid, I would check your DG, because if
you say you see a link, then it might be that in a column setting. Also check
how you are binding the DataSet to the DG.
--
adi
"Doru Roman" wrote:
Hi,

I write some code to retrieve information from Database.
After I bind the DBGrid it shows the result somehow like a link to the
Table.
When I click on the Table link it displays the whole content. It probably
has
to do with parent-child relationship, but I only have one result set.
Here is the code that accesses Northwind database:

SqlConnection conn = new SqlConnection("data source=YOUR-136F2019DC;initial
catalog=Northwind;password=mypassword;persist security info=True;user
id=sa;workstation id=YOUR-136F2019DC;packet size=4096");

conn.Open();

SqlCommand cmd1 = conn.CreateCommand();

cmd1.CommandText = "Select top 100 * from Customers";

cmd1.CommandType = CommandType.Text;

SqlCommand cmdCust = conn.CreateCommand();

cmdCust.CommandText = "Select top 100 * from Customers";

cmdCust.CommandType = CommandType.Text;

SqlDataAdapter daCust = new SqlDataAdapter(cmdCust);

DataSet dsCust = new DataSet();

daCust.Fill(dsCust);

dgCust.DataSource = dsCust;

dgCust.Expand(-1);

conn.Close();

It's probably some setting I am not aware of.

Thanks,

Doru

Jan 27 '06 #2
Thanks for the reply.
When I cut the sample I forgot to take out the first command which does not
influence the grid.
Aside from the code I do not set anything else for the grid. It first shows
a one column with a +
sign in the checkbox(the collapse sign) which has a line that connects to a
text box in which there is a link
with "Table" as text. When I click inside the text box on the Table link,
then the grid shows the whole
content of the query. On the sleeve of the grid a left arrow shows which has
this caption:
"Navigate back to the parent row". It's like it consider the result of the
query as a child recordset and I don't
know why.
The only way I bind the grid is through code.
Jan 27 '06 #3
Seems like a pre-designed grid. I did use this type of DG a while ago, and
all the settings were made from the HTML view of the Grid. You may want to
first view the DG in deisgn view and then go to its properties to see where
are those '+' signs and the link that says 'Navigate...' I bet there is also
a relation specified in the HTML code.

HTH

--
adi
"Doru Roman" wrote:
Thanks for the reply.
When I cut the sample I forgot to take out the first command which does not
influence the grid.
Aside from the code I do not set anything else for the grid. It first shows
a one column with a +
sign in the checkbox(the collapse sign) which has a line that connects to a
text box in which there is a link
with "Table" as text. When I click inside the text box on the Table link,
then the grid shows the whole
content of the query. On the sleeve of the grid a left arrow shows which has
this caption:
"Navigate back to the parent row". It's like it consider the result of the
query as a child recordset and I don't
know why.
The only way I bind the grid is through code.

Jan 27 '06 #4
It doesn't matter whether I use a grid control from the toolbox or I create
it by code, it behaves the same.
Please try the code I provided to see if you get a different display.
Jan 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ramtin | last post by:
Hi I have a DBGrid which returns some Arabic data .The charset of web page is utf-8 and anything on page is OK except DBGrid header titles . I set these titles through DBGrid Property Builder ,...
0
by: Ramtin | last post by:
Hi I have a DBGrid which returns some Arabic data .The charset of web page is utf-8 and anything on page is OK except DBGrid header titles . I set these titles through DBGrid Property Builder ,...
8
by: Chad Z. Hower aka Kudzu | last post by:
CurrentSelectedIndex of course wont work - user can resort rows by clicking on a column title and then index of the grid won't reflect the same order as the bound data table. Currently the code...
0
by: basha | last post by:
hi friends, I am usieng Dbgrid in my asp.net project, my requirement is in dbgrid i am displaying 10 records per page and i place one button on a webform for each record i am generating one...
1
by: Bill | last post by:
I need help!!! I have a form that is populated with a dbgrid from a Access database. When I open the form, it has 17 records. When i click on a record, I need a different form to open and go to...
3
by: nano9 | last post by:
Hola gente quisiera que alguien me pudiera ayudar con un problemilla que tengo, resulta que estoy programando en ASP con C# y estoy usando un cadbgrid que se comporta parecido a un datagrid o...
2
by: nano9 | last post by:
Hi. Maybe someone can help me with a small problem. I am programming in ASP using C# and I am using a cadbgrid which acts similar to a datagrid or dbgrid but it has some peculiarities that make for...
0
by: Quadran | last post by:
Hello everybody, I am new here and therefore hope nothing doing wrong, I have a DBGrid in C++ Builder 6.0 containing 26 cells and 12 rows In each cell there is a number stored and this...
1
by: stv972 | last post by:
Im a newbie in vb programming. i got to learn the loops thru books and surfing the net. Nwys im making a program now and m using dbgrid where i want to add data directly to the grid. I have already...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.