473,326 Members | 2,128 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,326 software developers and data experts.

Createing identity column in datatable



Hi,

I have created a datatable, dataadapter, added the table to a dataset
and filling the table.

Here I want to add an identity column to the above datatable and Later I
will use this identity colum for printing the records using print
document.

How to create an identity column that increments its value when each row
added to it.

Here is the code snippet... Pls help.

myCommand = New SqlClient.SqlCommand(mySql, gSQLConnection)
UsrAdapter = New SqlClient.SqlDataAdapter(myCommand)
myDataSet = New DataSet

Dim myDataTable As New DataTable("ShareHoldersAuditReport")
myDataSet.Tables.Add("ShareHoldersAuditReport")
Dim aColumn As DataColumn
aColumn = myconstraint
aColumn = New DataColumn("aaaa")
myDataSet.Tables("ShareHoldersAuditReport").Column s.Add(aColumn)
aColumn = New DataColumn("bbbb")
myDataSet.Tables("ShareHoldersAuditReport").Column s.Add(aColumn)
aColumn = New DataColumn("cccc")
myDataSet.Tables("ShareHoldersAuditReport").Column s.Add(aColumn)
UsrAdapter.Fill(myDataSet, "ShareHoldersAuditReport")
myTable = myDataSet.Tables("ShareHoldersAuditReport")
gSQLConnection.Close()

Regards.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
2 15601
Hi,

You have to make the column auto increment. Set the auto increment
seed to the starting value.
dsPriceList.Tables(0).Columns("ID").AutoIncrement = True

dsPriceList.Tables(0).Columns("ID").AutoIncrementS eed = 1

Ken

------------------------

"Omavlana Omav" <ki***@boardroomlimited.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...


Hi,

I have created a datatable, dataadapter, added the table to a dataset
and filling the table.

Here I want to add an identity column to the above datatable and Later I
will use this identity colum for printing the records using print
document.

How to create an identity column that increments its value when each row
added to it.

Here is the code snippet... Pls help.

myCommand = New SqlClient.SqlCommand(mySql, gSQLConnection)
UsrAdapter = New SqlClient.SqlDataAdapter(myCommand)
myDataSet = New DataSet

Dim myDataTable As New DataTable("ShareHoldersAuditReport")
myDataSet.Tables.Add("ShareHoldersAuditReport")
Dim aColumn As DataColumn
aColumn = myconstraint
aColumn = New DataColumn("aaaa")
myDataSet.Tables("ShareHoldersAuditReport").Column s.Add(aColumn)
aColumn = New DataColumn("bbbb")
myDataSet.Tables("ShareHoldersAuditReport").Column s.Add(aColumn)
aColumn = New DataColumn("cccc")
myDataSet.Tables("ShareHoldersAuditReport").Column s.Add(aColumn)
UsrAdapter.Fill(myDataSet, "ShareHoldersAuditReport")
myTable = myDataSet.Tables("ShareHoldersAuditReport")
gSQLConnection.Close()

Regards.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #2
AutoIncrement and AutoIncrementSeed are the properties you need to set.

NOTE: Be careful of database concurrency, et al, when heading this
direction, as it is easy to get the auto-increment out of touch with the
database.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Omavlana Omav" <ki***@boardroomlimited.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...


Hi,

I have created a datatable, dataadapter, added the table to a dataset
and filling the table.

Here I want to add an identity column to the above datatable and Later I
will use this identity colum for printing the records using print
document.

How to create an identity column that increments its value when each row
added to it.

Here is the code snippet... Pls help.

myCommand = New SqlClient.SqlCommand(mySql, gSQLConnection)
UsrAdapter = New SqlClient.SqlDataAdapter(myCommand)
myDataSet = New DataSet

Dim myDataTable As New DataTable("ShareHoldersAuditReport")
myDataSet.Tables.Add("ShareHoldersAuditReport")
Dim aColumn As DataColumn
aColumn = myconstraint
aColumn = New DataColumn("aaaa")
myDataSet.Tables("ShareHoldersAuditReport").Column s.Add(aColumn)
aColumn = New DataColumn("bbbb")
myDataSet.Tables("ShareHoldersAuditReport").Column s.Add(aColumn)
aColumn = New DataColumn("cccc")
myDataSet.Tables("ShareHoldersAuditReport").Column s.Add(aColumn)
UsrAdapter.Fill(myDataSet, "ShareHoldersAuditReport")
myTable = myDataSet.Tables("ShareHoldersAuditReport")
gSQLConnection.Close()

Regards.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #3

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

Similar topics

2
by: WhiteEagl | last post by:
Hello, I would need some help with this identity column problem in SQLServer. I have a database with two tables. The Parent table has an Identity column. Parent (ParentID IDENTITY, Name)...
6
by: Hardy Wang | last post by:
Hi all, I have the following codes, but SCOPE_IDENTITY() just returns NULL to me. If I comment out SCOPE_IDENTITY() line and run @@IDENTITY line, it works fine!! Since I have a trigger on the...
2
by: Danko Greiner | last post by:
I'm trying to update every table in DataSet, but getting inserted "id_user" gets me an exception: column "id_user" is read only if(_dataSet.HasChanges()) { SqlDataAdapter _adapter;...
3
by: Jason L James | last post by:
Hi all, I recently wrote a vb.net app using oledb to an access database. When I inserted new rows in my datatable the identity column was automatically created. This app used an un-typed...
3
by: Hugh O | last post by:
Hi, I am not sure if this type of question should be raised in this Newsgroup. If not please direct me. I am new to using RDO.Net data access but I thought I understood it. The 6 lines of...
5
by: David Thielen | last post by:
Hi; I am creating png files in my ASP .NET app. When I am running under Windows 2003/IIS 6, the file is not given the security permissions it should have. It does not have any permission for...
0
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, dataAdapter1.Fill(ds, "tbl1") say this adds 30 rows to tbl1. Then I want to add an Identity column to the table ds.Tables("tbl1").Columns.Add("tblID", ...
1
by: Tempera | last post by:
I add new row to DataTable (typed). I called TableAdapter.Upadte method. I noticed that field 'ItemId' (which is specified as Identity in SQL Server) has a value of new added item. This is great!...
1
by: Neeraj | last post by:
Hi all. I have stuck at a strange point.in Database some master table have identity column and some havenot. Then How can i know at runtimes that which table have identity column. According to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.