By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,304 Members | 3,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,304 IT Pros & Developers. It's quick & easy.

Not Showing Data Grid

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.