I want to count the number of records in a table, and insert a new record
with ID increment the count by 1.
Heres the code:
sqlStmt = "SELECT COUNT(*) As numRecords FROM TimeSlot;"
cmd = New SqlCommand(sqlS tmt, conn)
dr = cmd.ExecuteRead er
But how to get the value of numRecords? since numRecords is not a field in
table TimeSlot
please help! 2 1111
You can't until u've read through all of them. The datareader is a forward
only read-only quick way to look at data.
If you need to know the number up front, use a dataset or datatable.
"Matthew Louden" <ma*******@hotm ail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. I want to count the number of records in a table, and insert a new record with ID increment the count by 1.
Heres the code: sqlStmt = "SELECT COUNT(*) As numRecords FROM TimeSlot;" cmd = New SqlCommand(sqlS tmt, conn) dr = cmd.ExecuteRead er
But how to get the value of numRecords? since numRecords is not a field in table TimeSlot
please help!
This won't work for multiple database connections. The incremeted count
might give you false information. I assume that the ID is unique value? If
yes then change it in the database to be an identity field. If you do that
let me know and I will help you on how to get the new row inserted.
Ronen
"Matthew Louden" <ma*******@hotm ail.com> wrote in message
news:#X******** ******@tk2msftn gp13.phx.gbl... I want to count the number of records in a table, and insert a new record with ID increment the count by 1.
Heres the code: sqlStmt = "SELECT COUNT(*) As numRecords FROM TimeSlot;" cmd = New SqlCommand(sqlS tmt, conn) dr = cmd.ExecuteRead er
But how to get the value of numRecords? since numRecords is not a field in table TimeSlot
please help!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bryan Zash |
last post by:
When querying a bit field, I am encountering a problem with MS SQL
Server returning a larger number of records for a table than the
actual number of records that exist within that table.
For example, my customer table has 1 million unique records, so the
results of the following query are as such:
select count(customer_nbr) from customer = 1,000,000
There is bit field in the customer table that denotes whether a
|
by: usenet |
last post by:
I want to be able to use the record numbers of a sub-form, are they
available anyhow in VB (Access 2003)?
I want to use the sub-form record number as *part* of the primary key
for the table whose data is displayed on the sub-form. The other part
of the primary key is the column used to join to the master table.
E.g. I have TableA (the master table) with a primary key TableA.Column1.
TableB which is shown in the sub-form has a primary...
|
by: Vadim |
last post by:
Hi!
I imported some table (about 1500 records) using "LOAD DATA LOCAL
INFILE..." (command line console). No warnings, no skipped, no deletes
- all the recored are written to be imported.
However, in MySQL Administrator UI tool I see completely different
number in the "Rows" column. Making a SELECT query shows that the
actual number of records in the table is the correct one (the same
number as in text file table). Command line SHOW TABLE...
|
by: King |
last post by:
Hi
I have following MS Acess query
Here is the query
ID Name Prgm ID Client ID Date Start Time End
Time Minutes
C4 Trisha TIP DEK0703 7 /7 /2006 10:00:00 AM 12:00:00 PM
120
|
by: slickdock |
last post by:
I need to break my query into 3 groups:
First 60 records (records 1-60)
Next 60 records (records 61-121)
Next 60 records (records 122-182)
Of course I could use top values 60 for the first query, but where do
I go from there?
| |
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...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
| |
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |