473,473 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Not Showing Data Grid

Hi All,

I have an application that fetch data thru a store proc and display in a
datagrid, but after successful execution of proc the data grid is not
visible.Please go thru the following code and plz let me know what is
missing.The data grid propertiy "Visible is true".

try
{
OracleDataAccess oracleDA = new OracleDataAccess("Data
Source=dsname;User ID=uid;Password=pwd");
if (oracleDA.OpenDBConnection() == false)
{
return;
}
OracleConnection oracleConn = oracleDA.DBConnection;

OracleCommand psCommand = new
OracleCommand("PKG_NAME.STORED_PROC_NAME", oracleConn);
psCommand.CommandType = CommandType.StoredProcedure;

OracleParameter param = new OracleParameter("RESULT_CURSOR",
OracleType.Cursor);
param.Direction = ParameterDirection.Output;
psCommand.Parameters.Add(param);

param = new OracleParameter("IN_DATE", OracleType.VarChar);
param.Direction = ParameterDirection.Input;
param.Value = txtBoxBeginDate.Text;
psCommand.Parameters.Add(param);

// Execute command
OracleDataReader reader = psCommand.ExecuteReader();

if (!reader.HasRows)
{
reader.Close();
return;
}
OracleDataAdapter odad = new OracleDataAdapter(psCommand);

DataSet ds = new DataSet();

odad.Fill(ds);

GridView1.DataSource = ds;
GridView1.DataBind();
oracleConn.Close();
}
catch (Exception ex)
{

}

Thanks and Regards
Rinu G Pillai
Sep 12 '07 #1
4 2543
Rinu,

It seems that you are not setting the data member of the grid to point
to the table to bind to. This needs to be done for the DataGridView. If
you are using a DataGrid view, then I believe just setting the data set
should work.

Try to set the data source to the DataTable in the DataSet you just
filled.

If that doesn't work, then check to see that you are actually getting
results from the stored procedure, as that's always a possibility.

Also, if you are using the DataGridView, then make sure the
AutoGenerateColumns property is set to true, or, if it is false, make sure
you add the columns to be bound to.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rinu Gopalakrishna Pillai"
<Ri*********************@discussions.microsoft.com wrote in message
news:DE**********************************@microsof t.com...
Hi All,

I have an application that fetch data thru a store proc and display in a
datagrid, but after successful execution of proc the data grid is not
visible.Please go thru the following code and plz let me know what is
missing.The data grid propertiy "Visible is true".

try
{
OracleDataAccess oracleDA = new OracleDataAccess("Data
Source=dsname;User ID=uid;Password=pwd");
if (oracleDA.OpenDBConnection() == false)
{
return;
}
OracleConnection oracleConn = oracleDA.DBConnection;

OracleCommand psCommand = new
OracleCommand("PKG_NAME.STORED_PROC_NAME", oracleConn);
psCommand.CommandType = CommandType.StoredProcedure;

OracleParameter param = new OracleParameter("RESULT_CURSOR",
OracleType.Cursor);
param.Direction = ParameterDirection.Output;
psCommand.Parameters.Add(param);

param = new OracleParameter("IN_DATE", OracleType.VarChar);
param.Direction = ParameterDirection.Input;
param.Value = txtBoxBeginDate.Text;
psCommand.Parameters.Add(param);

// Execute command
OracleDataReader reader = psCommand.ExecuteReader();

if (!reader.HasRows)
{
reader.Close();
return;
}
OracleDataAdapter odad = new OracleDataAdapter(psCommand);

DataSet ds = new DataSet();

odad.Fill(ds);

GridView1.DataSource = ds;
GridView1.DataBind();
oracleConn.Close();
}
catch (Exception ex)
{

}

Thanks and Regards
Rinu G Pillai

Sep 12 '07 #2
Hi Nic,

Thanks a lot for your quick response.

The real problem was "AutoGenerateColumns = false" , now I changed to true
and it's working.

Nic, highly appreciate if you can show some code to do the rest of the
solution you mentioned , like
1 . set the data source to the DataTable in the DataSet

2 . setting the data member of the grid to point
to the table to bind to

3 .add the columns to be bound to

Once again thanks a lot!!!!.
"Nicholas Paldino [.NET/C# MVP]" wrote:
Rinu,

It seems that you are not setting the data member of the grid to point
to the table to bind to. This needs to be done for the DataGridView. If
you are using a DataGrid view, then I believe just setting the data set
should work.

Try to set the data source to the DataTable in the DataSet you just
filled.

If that doesn't work, then check to see that you are actually getting
results from the stored procedure, as that's always a possibility.

Also, if you are using the DataGridView, then make sure the
AutoGenerateColumns property is set to true, or, if it is false, make sure
you add the columns to be bound to.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rinu Gopalakrishna Pillai"
<Ri*********************@discussions.microsoft.com wrote in message
news:DE**********************************@microsof t.com...
Hi All,

I have an application that fetch data thru a store proc and display in a
datagrid, but after successful execution of proc the data grid is not
visible.Please go thru the following code and plz let me know what is
missing.The data grid propertiy "Visible is true".

try
{
OracleDataAccess oracleDA = new OracleDataAccess("Data
Source=dsname;User ID=uid;Password=pwd");
if (oracleDA.OpenDBConnection() == false)
{
return;
}
OracleConnection oracleConn = oracleDA.DBConnection;

OracleCommand psCommand = new
OracleCommand("PKG_NAME.STORED_PROC_NAME", oracleConn);
psCommand.CommandType = CommandType.StoredProcedure;

OracleParameter param = new OracleParameter("RESULT_CURSOR",
OracleType.Cursor);
param.Direction = ParameterDirection.Output;
psCommand.Parameters.Add(param);

param = new OracleParameter("IN_DATE", OracleType.VarChar);
param.Direction = ParameterDirection.Input;
param.Value = txtBoxBeginDate.Text;
psCommand.Parameters.Add(param);

// Execute command
OracleDataReader reader = psCommand.ExecuteReader();

if (!reader.HasRows)
{
reader.Close();
return;
}
OracleDataAdapter odad = new OracleDataAdapter(psCommand);

DataSet ds = new DataSet();

odad.Fill(ds);

GridView1.DataSource = ds;
GridView1.DataBind();
oracleConn.Close();
}
catch (Exception ex)
{

}

Thanks and Regards
Rinu G Pillai


Sep 12 '07 #3
Rinu,

If you want to bind to the data table, then you can get the table
yourself by accessing the Tables property on the DataSet. If you want to
use the DataMember property on the DataGridView, then you can set the
DataSource property to the DataSet instance and then set the DataMember
property to the name of the table, the same thing you would pass to the
string indexer for the collection returned by the Tables property.

To add the columns to bind to, you would have to call the Add method on
the DataGridViewColumnCollection which is exposed by the Columns property on
the DataGridView.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rinu Gopalakrishna Pillai"
<Ri*********************@discussions.microsoft.com wrote in message
news:A3**********************************@microsof t.com...
Hi Nic,

Thanks a lot for your quick response.

The real problem was "AutoGenerateColumns = false" , now I changed to true
and it's working.

Nic, highly appreciate if you can show some code to do the rest of the
solution you mentioned , like
1 . set the data source to the DataTable in the DataSet

2 . setting the data member of the grid to point
to the table to bind to

3 .add the columns to be bound to

Once again thanks a lot!!!!.
"Nicholas Paldino [.NET/C# MVP]" wrote:
>Rinu,

It seems that you are not setting the data member of the grid to
point
to the table to bind to. This needs to be done for the DataGridView. If
you are using a DataGrid view, then I believe just setting the data set
should work.

Try to set the data source to the DataTable in the DataSet you just
filled.

If that doesn't work, then check to see that you are actually getting
results from the stored procedure, as that's always a possibility.

Also, if you are using the DataGridView, then make sure the
AutoGenerateColumns property is set to true, or, if it is false, make
sure
you add the columns to be bound to.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rinu Gopalakrishna Pillai"
<Ri*********************@discussions.microsoft.co mwrote in message
news:DE**********************************@microso ft.com...
Hi All,

I have an application that fetch data thru a store proc and display in
a
datagrid, but after successful execution of proc the data grid is not
visible.Please go thru the following code and plz let me know what is
missing.The data grid propertiy "Visible is true".

try
{
OracleDataAccess oracleDA = new OracleDataAccess("Data
Source=dsname;User ID=uid;Password=pwd");
if (oracleDA.OpenDBConnection() == false)
{
return;
}
OracleConnection oracleConn = oracleDA.DBConnection;

OracleCommand psCommand = new
OracleCommand("PKG_NAME.STORED_PROC_NAME", oracleConn);
psCommand.CommandType = CommandType.StoredProcedure;

OracleParameter param = new OracleParameter("RESULT_CURSOR",
OracleType.Cursor);
param.Direction = ParameterDirection.Output;
psCommand.Parameters.Add(param);

param = new OracleParameter("IN_DATE", OracleType.VarChar);
param.Direction = ParameterDirection.Input;
param.Value = txtBoxBeginDate.Text;
psCommand.Parameters.Add(param);

// Execute command
OracleDataReader reader = psCommand.ExecuteReader();

if (!reader.HasRows)
{
reader.Close();
return;
}
OracleDataAdapter odad = new OracleDataAdapter(psCommand);

DataSet ds = new DataSet();

odad.Fill(ds);

GridView1.DataSource = ds;
GridView1.DataBind();
oracleConn.Close();
}
catch (Exception ex)
{

}

Thanks and Regards
Rinu G Pillai



Sep 12 '07 #4
Hi,

"Rinu Gopalakrishna Pillai"
<Ri*********************@discussions.microsoft.com wrote in message
news:A3**********************************@microsof t.com...
Hi Nic,

Thanks a lot for your quick response.

The real problem was "AutoGenerateColumns = false" , now I changed to true
and it's working.
A more fine grained control can be obtained by using TemplateColumns
instead. Especially regarding the header text of the column.

Sep 12 '07 #5

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

Similar topics

1
by: Schu | last post by:
I am trying to show a grid in a text box in an aspx page but I am not able to convert the GUID to a string. Here is the line I am trying to get to work: textbox1.text =...
1
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
0
by: John | last post by:
Hi! Guys I think some of you can help me here. Here is the situation...... I have a following columns from different tables and get a Dataset to Bind with a data grid. 1)ItemId int...
4
by: Alan Silver | last post by:
hello, I have a database table that stores names of schools, and I want o write a page that allows someone to change the list. I was wondering about showing the schools in a table, with...
2
by: tshad | last post by:
I have a Datagrid that has no rows in it, but I want the title to show, and they aren't. Is there a way to make them visible even if the Datagrid is empty? Thanks, Tom
6
by: Sebastian Santacroce | last post by:
How do I get a datetime field from a database to show just time in the datagrid. The default just shows date. Thank you Sebastian
2
by: Andy Savelle | last post by:
I have recently started working with Visual Basic .NET. Having very little experiance in VB .NET, I am starting from the gound up with very simple programs. One of my first task to achieve is...
2
by: TerryW | last post by:
I am using a system.windows.forms.datagrid and i set it's data source to a system.data.datatable which has a column that's dataType is system.dateTime. When I try to enter minutes and seconds...
6
by: ajk | last post by:
Hi I was wondering how to show different properties in design and run-mode for a user control? Is it possible to do this when implementing the System.ComponentModel.ICustomTypeDescriptor...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.