Datagrid Question

  • Thread starter ccshine via DotNetMonster.com
  • Start date
C

ccshine via DotNetMonster.com

I'm creating a winform application that implements a datagrid to display a
daily inventory for chemicals. If there is already data for a particular day,
that day's info will display in the grid. Otherwise, I want to just display
the list of all chemicals that are not marked as discontinued in the Access
database so that the user can enter that day's inventory count.

There are 2 database tables for this portion of the app. The chemicals table
contains... you guessed it - chemical information, and the dailyInventory
table contains the fk to chemicals and daily inventory counts for each
chemical.

My first approach to create the datagrid as described was to use a select
statement that populated a dataset and bind the dataset to the datagrid. I
tried several different join statements to accomplish this, but nothing
seemed to work the way I wanted it to. If there wasn't any data for a
particular day, the closest I could get was to display all the chemicals but
some of them had information from previous dates and others contained <null>.
So then I thought perhaps I should use a dataset from another screen to
populate the datagrid with the list of chemicals. However, I don't want to
bind that dataset to the grid since the data needs to go to dailyInventory
and not just chemicals.

Have I just missed the boat on the select and rowfilter statements or should
I use the second dataset instead? If I should use the second dataset, how do
I add items to the datagrid without binding it?
 
R

Radenko Zec

ccshine via DotNetMonster.com said:
I'm creating a winform application that implements a datagrid to display a
daily inventory for chemicals. If there is already data for a particular
day,
that day's info will display in the grid. Otherwise, I want to just
display
the list of all chemicals that are not marked as discontinued in the
Access
database so that the user can enter that day's inventory count.

There are 2 database tables for this portion of the app. The chemicals
table
contains... you guessed it - chemical information, and the dailyInventory
table contains the fk to chemicals and daily inventory counts for each
chemical.

My first approach to create the datagrid as described was to use a select
statement that populated a dataset and bind the dataset to the datagrid.
I
tried several different join statements to accomplish this, but nothing
seemed to work the way I wanted it to. If there wasn't any data for a
particular day, the closest I could get was to display all the chemicals
but
some of them had information from previous dates and others contained
<null>.
So then I thought perhaps I should use a dataset from another screen to
populate the datagrid with the list of chemicals. However, I don't want
to
bind that dataset to the grid since the data needs to go to dailyInventory
and not just chemicals.

Have I just missed the boat on the select and rowfilter statements or
should
I use the second dataset instead? If I should use the second dataset, how
do
I add items to the datagrid without binding it?






I recomend that your problem solve in T-sql
with use where and (if begin end else)
and with use of parameters.
If parameter name=...
Begin
Select....
End
Else
.....
 
C

ccshine via DotNetMonster.com

I guess I'm too much of a newbie to completely understand your proposed
solution. Can this be done with Access? I was using the connection string
to perform the join operation within the application because Access doesn't
support output parameters.

Radenko said:
I'm creating a winform application that implements a datagrid to display a
daily inventory for chemicals. If there is already data for a particular
[quoted text clipped - 31 lines]
do
I add items to the datagrid without binding it?

I recomend that your problem solve in T-sql
with use where and (if begin end else)
and with use of parameters.
If parameter name=...
Begin
Select....
End
Else
....
 
R

Radenko Zec

You can use OleDbReader to read data from tables.
Your problem is with transact sql.select ... where ColumnName Is Not Null
or where date between... or in...
 
C

ccshine via DotNetMonster.com

Thanks for the help. I actually found another way around this. I created a
dataset for the chemicals table. If the date is null, then I loop through
the second dataset and add the descriptions to the datagrid without the need
to change the datasource or perform some extravagent sql statement.

Radenko said:
You can use OleDbReader to read data from tables.
Your problem is with transact sql.select ... where ColumnName Is Not Null
or where date between... or in...
I'm creating a winform application that implements a datagrid to display a
daily inventory for chemicals. If there is already data for a particular
[quoted text clipped - 31 lines]
do
I add items to the datagrid without binding it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top