473,657 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Very Basic DataGrid Help Needed

jm
I manually put a datagrid in on a form. I then added this code to an
event to populate it:

OdbcConnection conn = new OdbcConnection( "DSN=CardBase") ;
sqlCardHolders = "SELECT * FROM tblcardholders " +
"WHERE last_name LIKE '%" + txtLastName.Tex t + "%'";
DataSet rs = new DataSet();
conn.Open();
OdbcDataAdapter myOdbcAdapter = new
OdbcDataAdapter (sqlCardHolders , conn);
myOdbcAdapter.F ill(rs);
dgridSearchResu lts.DataSource = rs;
dgridSearchResu lts.SetDataBind ing(rs,"CardHol ders");

I do not see anything in the datagrid except a little box with a plus
and I can eventually expand it to show the row and it lets me edit it,
etc.

If I turn off Row Headers Visible, I don't even see the little plus.

I just want to query the database and have the rows show up. I don't
want to edit them or anything. I just can't find anything that shows
me some basic tutorial on this. Thank you for any help.
Nov 16 '05 #1
1 1267
jm,

The DataGrid is doing that because you are assigning it a DataSet as a
DataSource. A DataSet contains a collection of Tables and possibly
Relationships between those tables. If you want to only represent the
DataTable in the collection represented by your single query, you'll need to
specify the DataSource as being the DefaultView of the table you want to
show.

For example:
dgridSearchResu lts.DataSource = rs.Tables[0].DefaultView;

Hope that helps,

Patrick Altman

"jm" <jo************ *@yahoo.com> wrote in message
news:c6******** *************** ***@posting.goo gle.com...
I manually put a datagrid in on a form. I then added this code to an
event to populate it:

OdbcConnection conn = new OdbcConnection( "DSN=CardBase") ;
sqlCardHolders = "SELECT * FROM tblcardholders " +
"WHERE last_name LIKE '%" + txtLastName.Tex t + "%'";
DataSet rs = new DataSet();
conn.Open();
OdbcDataAdapter myOdbcAdapter = new
OdbcDataAdapter (sqlCardHolders , conn);
myOdbcAdapter.F ill(rs);
dgridSearchResu lts.DataSource = rs;
dgridSearchResu lts.SetDataBind ing(rs,"CardHol ders");

I do not see anything in the datagrid except a little box with a plus
and I can eventually expand it to show the row and it lets me edit it,
etc.

If I turn off Row Headers Visible, I don't even see the little plus.

I just want to query the database and have the rows show up. I don't
want to edit them or anything. I just can't find anything that shows
me some basic tutorial on this. Thank you for any help.

Nov 16 '05 #2

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

Similar topics

0
1444
by: Chankama | last post by:
Hi. I am attempting to display the contents of a database table on a CE device. I was using a DataTable object, as the datasource of the DataGrid, to accomplish this task. The problem with this approach is that I need to read the whole table into memory before assigning it as the datasource of the DataGrid. Ideally, I should retrieve row by row as needed to save memory. Conceivably I could read a partial # of rows and refresh the...
5
2625
by: BethInAK | last post by:
Thank you in advance for any possible help you have to offer, before I pull my hair out! I am incredibly frustrated attempting to learn asp.net. Its really pissing me off. Please help. First, please tell me the best asp .net book to purchase for a stupid beginner, preferably with vb instead of C. I have no idea what most of the c code in my current book means and in trying to learn the .net stuff at the same time, its giving me...
1
2116
by: thegame | last post by:
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls Hello, I have an interesting dilemma. I have an ASPX page with two user controls (two ASCXs). Both ASCXs have DataGrids on them. The first user control's DataGrid is populated from our database on page load. The DataGrid also has a Select LinkButton.
2
2971
by: Fay Yocum | last post by:
BEWARE beginner questions!! I have some experience in Access but never as much as I want or need. I have decided to get in on VB.Net. I would only rate myself in Access as a Beginner/Intermediate VBA programmer. I have decided to go at learning VB.Net in a more organized manner. I have some questions where answers are not becoming clear with VB.Net. So here goes. 1 All of the books I have accessed do basic one-two form examples...
10
5656
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1) DsStudentCourse1.AcceptChanges() i'm also wondering because w/ out AcceptChanges the data is still save into the database and it is now faster.
10
8118
by: Aaron Smith | last post by:
If I have a datagrid and the bound data file only have 4 rows in it, the grid will show the 4 rows. However, there is blank space below that until it reaches the bottom of the grid. Is there a way to have a fixed number of rows regardless of what data is in the bound table? Thanks, Aaron -- --- Aaron Smith
10
4941
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than the column order of the datatable). I also allow the user to click on a column header to sort the datagrid by that column. I need to identify the row and column in the datatable when the user clicks on a cell in the datagrid. Using the...
5
3868
hussaini
by: hussaini | last post by:
please tell me any 1 printing code in datagrid in visual basic 6 in detail ----- Hello seniors members hope u will tell me ..... i have created a form in visual basic 6 so in the form there is a datagrid and a command button so i want to print the records in datagrid when i press that command button it open dailog like ms word CTRL + P its open of printing dailog hope u understand what i meant
1
13301
nateraaaa
by: nateraaaa | last post by:
While working on a recent project I discovered how useful the CommandArgument property can be. I needed to determine the record_id of a row displayed in my datagrid. When the user clicked the Edit ImageButton I needed to redirect the user to the Edit page where the data on the page would be prepopulated with data from the database. I tried several things without success then discovered that the CommandArgument property could be used for this...
0
8399
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
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
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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...
1
8504
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6169
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
5632
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();...
1
2732
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
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.