473,396 Members | 1,836 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.

How to get the value of counter field

I am using VB.NET 2005 and Access database.
In the database I have table (myTbl) with a column called ID as a primary
key, and it is a counter field.
When I insert into myTbl, how can I get the value of ID ?

Private m_cmd As OleDb.OleDbCommand

m_cmd = New OleDb.OleDbCommand
sSQL = "insert into myTbl (col1,col2) VALUES (?,?)"
m_cmd.Parameters.Add("@col1", OleDb.OleDbType.VarChar, 50, "col1")
m_cmd.Parameters.Add("@col2", OleDb.OleDbType.VarChar, 50, "col2")
m_cmd.Parameters("@col1").Value = sParameterValue1
m_cmd.Parameters("@col2").Value = sParameterValue2
With m_cmd
.Connection = adoConOLE
.CommandText = sSQL
End With
m_cmd.ExecuteNonQuery()

How can I get the value of the column ID ?
m_cmd.Parameters.Add("@ID" & sParameterName, OleDb.OleDbType.BigInt, 4,
"ID").Direction = ParameterDirection.Output '--Can I do this, and if I
can, is the following sql statement correct ?
insert into myTbl (col1,col2) VALUES (?,?)
Thank you.
Jan 14 '08 #1
1 1363
This is most certainly possible in Access, and from a bit of googling
you'll come up with hits that may include this one describing how to do
it:
http://msdn2.microsoft.com/en-us/lib...t0(VS.80).aspx
Why are you posting to microsoft.public.data.ado ?
IT IS NOT A .NET NEWSGROUP, it is for ADO, not ADO.NET

I am sick and tired of clueless .NET programmers continually posting to
microsoft.public.data.ado.
Microsoft created hundreds of .NET newsgroups, all with "dotnet" somewhere
in the newsgroup name.
If a newsgroup does not have "dotnet" in the name it is not a .NET
newsgroup.

If you cant distinguish newsgroups you should abandon progarmming, you are
not up to it.

Stephen Howe
Feb 28 '08 #2

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

Similar topics

2
by: Royse | last post by:
Hi Group I'm trying to get the value from a select and place it into some text fields. all these fields have the same name. when a user enters the page all fields are empty Then, when they click...
3
by: kaston3 | last post by:
var totalpoints=0; for (counter=1;....){ myvalue=parseFloat(document.forms.elements.value); totalpoints+=myvalue //the fields in elements are always numbers }
3
by: Poul Møller Hansen | last post by:
Hi, I need an auto incrementing field that will contain values like N000001, N000002, N000003 etc. I think the way is to use the value from an identity field in a stored procedure that is...
4
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it...
4
by: Ian Davies | last post by:
Hello I have seen some tutorials to put a update a counter field in a record. I have the counter field in a table that also has a field for a path to file. I display the records in a table on...
1
by: robing | last post by:
I am having trouble getting data from a text input field element. the element is called amount_$counter with $counter being the row of the table. when i have made an input to the text field and...
5
by: Veeru71 | last post by:
Given a table with an identity column (GENERATED BY DEFAULT AS IDENTITY), is there any way to get the last generated value by DB2 for the identity column? I can't use identity_val_local() as...
7
by: chanshaw | last post by:
Ok I'm looking to find the array index of the entered employee number here is my code #!/usr/bin/perl # Uses module Text::CSV # compiler directives use strict; use warnings; use Text::CSV;
0
by: grego9 | last post by:
I have a bit of visual basic code in an excel spreadsheet that I need some help with. I am attempting to search a file called TO Cancellations2.xls for counterparty names and for each counterparty...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.