473,686 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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;init ial
catalog=Northwi nd;password=myp assword;persist security info=True;user
id=sa;workstati on id=YOUR-136F2019DC;pack et size=4096");

conn.Open();

SqlCommand cmd1 = conn.CreateComm and();

cmd1.CommandTex t = "Select top 100 * from Customers";

cmd1.CommandTyp e = CommandType.Tex t;

SqlCommand cmdCust = conn.CreateComm and();

cmdCust.Command Text = "Select top 100 * from Customers";

cmdCust.Command Type = CommandType.Tex t;

SqlDataAdapter daCust = new SqlDataAdapter( cmdCust);

DataSet dsCust = new DataSet();

daCust.Fill(dsC ust);

dgCust.DataSour ce = dsCust;

dgCust.Expand(-1);

conn.Close();

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

Thanks,

Doru
Jan 27 '06 #1
4 1766
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;init ial
catalog=Northwi nd;password=myp assword;persist security info=True;user
id=sa;workstati on id=YOUR-136F2019DC;pack et size=4096");

conn.Open();

SqlCommand cmd1 = conn.CreateComm and();

cmd1.CommandTex t = "Select top 100 * from Customers";

cmd1.CommandTyp e = CommandType.Tex t;

SqlCommand cmdCust = conn.CreateComm and();

cmdCust.Command Text = "Select top 100 * from Customers";

cmdCust.Command Type = CommandType.Tex t;

SqlDataAdapter daCust = new SqlDataAdapter( cmdCust);

DataSet dsCust = new DataSet();

daCust.Fill(dsC ust);

dgCust.DataSour ce = 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
1956
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 , but on web page they can not be readable. What is problem? Thanks K.Ramtin
0
1412
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 , but on web page they can not be readable. What is problem? Thanks K.Ramtin
8
2818
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 is doing this: CurrencyManager xCM = (CurrencyManager)BindingContext; DataRowView xDRV = (DataRowView)xCM.Current; _Vendor = (AdminWS.VendorListDS.VendorRow)xDRV.Row;
0
1475
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 checkbox, that i place in template of dbgrid, when the user select checkboxs of rows all the rows should be deleted (I am displaying date in dbgrid from oracle database) for that i am not getting code, pls can u help me i have dead line now i am...
1
2642
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 the related record from the first form. Table relationships are; tbl 1 fld -action id
3
2898
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 dbgrid pero tiene otras peculiaridades ahi que facilitan muchas tareas. Si alguno ha usado este control talvez me podria ayudar. El asunto esta asi, estoy queriendo agregar un mensaje en una etiqueta debajo del grid para indicar la cantidad de items...
2
1588
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 a lot of work. If anyone has used this control maybe you can help me. The problem is this: I want to put together a message below the grid to indicate the number of items shown on a page, the item totals and the page number. The message...
0
1702
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 number can be 0,1->10, -1 or -9 each representing a code.
1
2441
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 textboxes coded for data entry but i recently found out that i can directly enter data using the grid. I already set custom properties of dbgrid AllowAddNew, AllowDelete and AllowUpdate to true but it seems the grid is still lock even though there...
0
8520
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8936
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7603
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6442
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5800
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2953
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.