473,796 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid record count

Hi guys,

I have a problem with a datagrid record count. Here is the code:-

<snip>

Public Class frmMerchantDepo sit
Inherits System.Windows. Forms.Form

Dim myconnection As New Odbc.OdbcConnec tion("DSN=datab ase")
Dim dsMerchant As DataSet
Dim daMerchant As Odbc.OdbcDataAd apter

Private Sub frmMerchantDepo sit_Load(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles MyBase.Load

myconnection.Op en()
Dim mysql As String
mysql = "Select * from qryInvoice WHERE NOT Posted"
daMerchant = New Odbc.OdbcDataAd apter(mysql, myconnection)
dsMerchant = New DataSet
daMerchant.Fill (dsMerchant, "Merchant")

DataGridBatchMe rchant.DataSour ce = dsMerchant.Tabl es("Merchant")
Dim tsMerchant As New DataGridTableSt yle
tsMerchant.Mapp ingName = "Merchant"
tsMerchant.Alte rnatingBackColo r = System.Drawing. Color.Gold
DataGridBatchMe rchant.TableSty les.Clear()

Dim cstbInvoiceDate As New DataGridTextBox Column
With cstbInvoiceDate
.MappingName = "InvoiceDat e"
.HeaderText = "Date"
.Width = 80
End With

Dim cstbFirstName As New DataGridTextBox Column
With cstbFirstName
.MappingName = "FirstName"
.HeaderText = "First Name"
.Width = 150
End With

Dim cstbLastName As New DataGridTextBox Column
With cstbLastName
.MappingName = "LastName"
.HeaderText = "Last Name"
.Width = 150
End With

tsMerchant.Grid ColumnStyles.Ad d(cstbInvoiceDa te)
tsMerchant.Grid ColumnStyles.Ad d(cstbFirstName )
tsMerchant.Grid ColumnStyles.Ad d(cstbLastName)

DataGridBatchMe rchant.TableSty les.Add(tsMerch ant)
DataGridBatchMe rchant.Visible = True
lblRecordNumber .Text = "There are " &
dsMerchant.Tabl es(0).Rows.Coun t & " records in the table"
'.............. .first record count
myconnection.Cl ose()

End Sub
Private Sub btnSave_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSave.Click

MsgBox("There are " & dsMerchant.Tabl es(0).Rows.Coun t & " records in
the table") '.............. ......second record count
If dsMerchant.Tabl es(0).Rows.Coun t > 0 Then
'do stuff
End If

End Sub

End Class

</snip>

In the first record count in the .Load class I get zero records, the dataset
is empty. On the second I get a count of one but have not added any records.
Any ideas as to why?

Cheers

Peter.

Mar 25 '06 #1
4 3091
Hi,

You specify a name when filling the dataset. Try
dsMerchant.Tabl es("Merchant"). Rows.Count

Ken
-----------------
"Peter W Johnson" <vk****@yahoo.c om> wrote in message
news:uE******** *****@TK2MSFTNG P09.phx.gbl...
Hi guys,

I have a problem with a datagrid record count. Here is the code:-

<snip>

Public Class frmMerchantDepo sit
Inherits System.Windows. Forms.Form

Dim myconnection As New Odbc.OdbcConnec tion("DSN=datab ase")
Dim dsMerchant As DataSet
Dim daMerchant As Odbc.OdbcDataAd apter

Private Sub frmMerchantDepo sit_Load(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load

myconnection.Op en()
Dim mysql As String
mysql = "Select * from qryInvoice WHERE NOT Posted"
daMerchant = New Odbc.OdbcDataAd apter(mysql, myconnection)
dsMerchant = New DataSet
daMerchant.Fill (dsMerchant, "Merchant")

DataGridBatchMe rchant.DataSour ce = dsMerchant.Tabl es("Merchant")
Dim tsMerchant As New DataGridTableSt yle
tsMerchant.Mapp ingName = "Merchant"
tsMerchant.Alte rnatingBackColo r = System.Drawing. Color.Gold
DataGridBatchMe rchant.TableSty les.Clear()

Dim cstbInvoiceDate As New DataGridTextBox Column
With cstbInvoiceDate
.MappingName = "InvoiceDat e"
.HeaderText = "Date"
.Width = 80
End With

Dim cstbFirstName As New DataGridTextBox Column
With cstbFirstName
.MappingName = "FirstName"
.HeaderText = "First Name"
.Width = 150
End With

Dim cstbLastName As New DataGridTextBox Column
With cstbLastName
.MappingName = "LastName"
.HeaderText = "Last Name"
.Width = 150
End With

tsMerchant.Grid ColumnStyles.Ad d(cstbInvoiceDa te)
tsMerchant.Grid ColumnStyles.Ad d(cstbFirstName )
tsMerchant.Grid ColumnStyles.Ad d(cstbLastName)

DataGridBatchMe rchant.TableSty les.Add(tsMerch ant)
DataGridBatchMe rchant.Visible = True
lblRecordNumber .Text = "There are " &
dsMerchant.Tabl es(0).Rows.Coun t & " records in the table"
'.............. .first record count
myconnection.Cl ose()

End Sub
Private Sub btnSave_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSave.Click

MsgBox("There are " & dsMerchant.Tabl es(0).Rows.Coun t & " records
in the table") '.............. ......second record count
If dsMerchant.Tabl es(0).Rows.Coun t > 0 Then
'do stuff
End If

End Sub

End Class

</snip>

In the first record count in the .Load class I get zero records, the
dataset is empty. On the second I get a count of one but have not added
any records. Any ideas as to why?

Cheers

Peter.

Mar 27 '06 #2
Peter,

Is that happen as well as you eliminate all that style code.

(I do not see the sense here why you show that to us.)

Cor
Mar 27 '06 #3
Cor,

I included it because I thought it may be relavant.

Cheers

Peter.
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:Oa******** *****@TK2MSFTNG P09.phx.gbl...
Peter,

Is that happen as well as you eliminate all that style code.

(I do not see the sense here why you show that to us.)

Cor

Mar 28 '06 #4
Ken,

Thanks but no difference.

Cheers

Peter.
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l...
Hi,

You specify a name when filling the dataset. Try
dsMerchant.Tabl es("Merchant"). Rows.Count

Ken
-----------------
"Peter W Johnson" <vk****@yahoo.c om> wrote in message
news:uE******** *****@TK2MSFTNG P09.phx.gbl...
Hi guys,

I have a problem with a datagrid record count. Here is the code:-

<snip>

Public Class frmMerchantDepo sit
Inherits System.Windows. Forms.Form

Dim myconnection As New Odbc.OdbcConnec tion("DSN=datab ase")
Dim dsMerchant As DataSet
Dim daMerchant As Odbc.OdbcDataAd apter

Private Sub frmMerchantDepo sit_Load(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load

myconnection.Op en()
Dim mysql As String
mysql = "Select * from qryInvoice WHERE NOT Posted"
daMerchant = New Odbc.OdbcDataAd apter(mysql, myconnection)
dsMerchant = New DataSet
daMerchant.Fill (dsMerchant, "Merchant")

DataGridBatchMe rchant.DataSour ce = dsMerchant.Tabl es("Merchant")
Dim tsMerchant As New DataGridTableSt yle
tsMerchant.Mapp ingName = "Merchant"
tsMerchant.Alte rnatingBackColo r = System.Drawing. Color.Gold
DataGridBatchMe rchant.TableSty les.Clear()

Dim cstbInvoiceDate As New DataGridTextBox Column
With cstbInvoiceDate
.MappingName = "InvoiceDat e"
.HeaderText = "Date"
.Width = 80
End With

Dim cstbFirstName As New DataGridTextBox Column
With cstbFirstName
.MappingName = "FirstName"
.HeaderText = "First Name"
.Width = 150
End With

Dim cstbLastName As New DataGridTextBox Column
With cstbLastName
.MappingName = "LastName"
.HeaderText = "Last Name"
.Width = 150
End With

tsMerchant.Grid ColumnStyles.Ad d(cstbInvoiceDa te)
tsMerchant.Grid ColumnStyles.Ad d(cstbFirstName )
tsMerchant.Grid ColumnStyles.Ad d(cstbLastName)

DataGridBatchMe rchant.TableSty les.Add(tsMerch ant)
DataGridBatchMe rchant.Visible = True
lblRecordNumber .Text = "There are " &
dsMerchant.Tabl es(0).Rows.Coun t & " records in the table"
'.............. .first record count
myconnection.Cl ose()

End Sub
Private Sub btnSave_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSave.Click

MsgBox("There are " & dsMerchant.Tabl es(0).Rows.Coun t & " records
in the table") '.............. ......second record count
If dsMerchant.Tabl es(0).Rows.Coun t > 0 Then
'do stuff
End If

End Sub

End Class

</snip>

In the first record count in the .Load class I get zero records, the
dataset is empty. On the second I get a count of one but have not added
any records. Any ideas as to why?

Cheers

Peter.


Mar 28 '06 #5

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

Similar topics

5
9178
by: BBFrost | last post by:
Win2000 ..Net 1.1 SP1 c# using Visual Studio Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1 datagrid. I've come to realize that a 'block' of rows highlighted within a datagrid do >> not << constitute a set of 'selected' records. Apparently one and only one row may be 'selected' in a datagrid. By selected row I mean the row
4
5357
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. Currently everything is working. I can find the updated rows/columns by parsing the posted data collection against the DataGrid DataSource. However, when there is a large amount of DataGridItems (rows) the update processing can take a while. ...
3
4886
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
2
6968
by: DC Gringo | last post by:
I have a datagrid control that has paging set up and working. What I would like is a total record count (not just per page) in the header or near the header of the datagrid. Here's my code: <asp:DataGrid AllowCustomPaging="false" AllowPaging="true" AllowSorting="true"
9
5068
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ******************************************************************************* <asp:DataGrid visible="False" border=1
0
1335
by: slinky | last post by:
I'm using VS2003 VB.net/ASP.net and have a Datagrid on an .ASPX page that is successfully displaying the records I was expecting. The next step I want to do is to double-click a line (record) and launch another page that has the more details of that record displayed (and of course only that record). Can anyone give some lues or hyperlinks to accomplishing this? I've heard of using DataView, but I don't think this is available in the...
8
1258
by: brock wade | last post by:
I have a Datagrid that is working fine displying my records, but I'm trying to program buttons on each record line to launch another web page that shows all the details for the product: <asp:datagrid id="dgProducts" runat="server"> <asp:ButtonColumn Text="Details" CommandName="Details" ButtonType="PushButton"></asp:ButtonColumn> </asp:datagrid>
0
1308
by: slinky | last post by:
I'm using VS2003 VB.net/ASP.net and have a Datagrid on an .ASPX page that is successfully displaying the records I was expecting. The next step I want to do is to double-click a line (record) and launch another page that has the more details of that record displayed (and of course only that record). Can anyone give some lues or hyperlinks to accomplishing this? I've heard of using DataView, but I don't think this is available in the...
1
1888
by: Brock | last post by:
First note that I am using Framework 1.1. I have an .aspx page that is displaying a list of employees, but only the Employee Number, First Name, Last Name, and Title. It is working great. I recessed it in a <Div></Divto allow scrolling of just the data, not the page. What I need to do is place a DataList (also in a <Div></Divto allow scrolling of just the data) to the right of the Datagrid to show 40 Employee Detail fields (listed top to...
0
9685
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...
1
10187
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,...
0
9055
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
7553
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
6795
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
5446
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...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
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.