473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Datagrid record count

Hi guys,

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

<snip>

Public Class frmMerchantDeposit
Inherits System.Windows.Forms.Form

Dim myconnection As New Odbc.OdbcConnection("DSN=database")
Dim dsMerchant As DataSet
Dim daMerchant As Odbc.OdbcDataAdapter

Private Sub frmMerchantDeposit_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load

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

DataGridBatchMerchant.DataSource = dsMerchant.Tables("Merchant")
Dim tsMerchant As New DataGridTableStyle
tsMerchant.MappingName = "Merchant"
tsMerchant.AlternatingBackColor = System.Drawing.Color.Gold
DataGridBatchMerchant.TableStyles.Clear()

Dim cstbInvoiceDate As New DataGridTextBoxColumn
With cstbInvoiceDate
.MappingName = "InvoiceDate"
.HeaderText = "Date"
.Width = 80
End With

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

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

tsMerchant.GridColumnStyles.Add(cstbInvoiceDate)
tsMerchant.GridColumnStyles.Add(cstbFirstName)
tsMerchant.GridColumnStyles.Add(cstbLastName)

DataGridBatchMerchant.TableStyles.Add(tsMerchant)
DataGridBatchMerchant.Visible = True
lblRecordNumber.Text = "There are " &
dsMerchant.Tables(0).Rows.Count & " records in the table"
'...............first record count
myconnection.Close()

End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click

MsgBox("There are " & dsMerchant.Tables(0).Rows.Count & " records in
the table") '....................second record count
If dsMerchant.Tables(0).Rows.Count > 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 3069
Hi,

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

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

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

<snip>

Public Class frmMerchantDeposit
Inherits System.Windows.Forms.Form

Dim myconnection As New Odbc.OdbcConnection("DSN=database")
Dim dsMerchant As DataSet
Dim daMerchant As Odbc.OdbcDataAdapter

Private Sub frmMerchantDeposit_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

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

DataGridBatchMerchant.DataSource = dsMerchant.Tables("Merchant")
Dim tsMerchant As New DataGridTableStyle
tsMerchant.MappingName = "Merchant"
tsMerchant.AlternatingBackColor = System.Drawing.Color.Gold
DataGridBatchMerchant.TableStyles.Clear()

Dim cstbInvoiceDate As New DataGridTextBoxColumn
With cstbInvoiceDate
.MappingName = "InvoiceDate"
.HeaderText = "Date"
.Width = 80
End With

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

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

tsMerchant.GridColumnStyles.Add(cstbInvoiceDate)
tsMerchant.GridColumnStyles.Add(cstbFirstName)
tsMerchant.GridColumnStyles.Add(cstbLastName)

DataGridBatchMerchant.TableStyles.Add(tsMerchant)
DataGridBatchMerchant.Visible = True
lblRecordNumber.Text = "There are " &
dsMerchant.Tables(0).Rows.Count & " records in the table"
'...............first record count
myconnection.Close()

End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click

MsgBox("There are " & dsMerchant.Tables(0).Rows.Count & " records
in the table") '....................second record count
If dsMerchant.Tables(0).Rows.Count > 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*************@TK2MSFTNGP09.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***@bellsouth.net> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
Hi,

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

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

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

<snip>

Public Class frmMerchantDeposit
Inherits System.Windows.Forms.Form

Dim myconnection As New Odbc.OdbcConnection("DSN=database")
Dim dsMerchant As DataSet
Dim daMerchant As Odbc.OdbcDataAdapter

Private Sub frmMerchantDeposit_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

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

DataGridBatchMerchant.DataSource = dsMerchant.Tables("Merchant")
Dim tsMerchant As New DataGridTableStyle
tsMerchant.MappingName = "Merchant"
tsMerchant.AlternatingBackColor = System.Drawing.Color.Gold
DataGridBatchMerchant.TableStyles.Clear()

Dim cstbInvoiceDate As New DataGridTextBoxColumn
With cstbInvoiceDate
.MappingName = "InvoiceDate"
.HeaderText = "Date"
.Width = 80
End With

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

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

tsMerchant.GridColumnStyles.Add(cstbInvoiceDate)
tsMerchant.GridColumnStyles.Add(cstbFirstName)
tsMerchant.GridColumnStyles.Add(cstbLastName)

DataGridBatchMerchant.TableStyles.Add(tsMerchant)
DataGridBatchMerchant.Visible = True
lblRecordNumber.Text = "There are " &
dsMerchant.Tables(0).Rows.Count & " records in the table"
'...............first record count
myconnection.Close()

End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click

MsgBox("There are " & dsMerchant.Tables(0).Rows.Count & " records
in the table") '....................second record count
If dsMerchant.Tables(0).Rows.Count > 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
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...
4
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. ...
3
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...
2
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: ...
9
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: ...
0
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...
8
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: ...
0
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
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,...
0
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...

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.