473,666 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.SqlCo mmand(mySql, gSQLConnection)
UsrAdapter = New SqlClient.SqlDa taAdapter(myCom mand)
myDataSet = New DataSet

Dim myDataTable As New DataTable("Shar eHoldersAuditRe port")
myDataSet.Table s.Add("ShareHol dersAuditReport ")
Dim aColumn As DataColumn
aColumn = myconstraint
aColumn = New DataColumn("aaa a")
myDataSet.Table s("ShareHolders AuditReport").C olumns.Add(aCol umn)
aColumn = New DataColumn("bbb b")
myDataSet.Table s("ShareHolders AuditReport").C olumns.Add(aCol umn)
aColumn = New DataColumn("ccc c")
myDataSet.Table s("ShareHolders AuditReport").C olumns.Add(aCol umn)
UsrAdapter.Fill (myDataSet, "ShareHoldersAu ditReport")
myTable = myDataSet.Table s("ShareHolders AuditReport")
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 15633
Hi,

You have to make the column auto increment. Set the auto increment
seed to the starting value.
dsPriceList.Tab les(0).Columns( "ID").AutoIncre ment = True

dsPriceList.Tab les(0).Columns( "ID").AutoIncre mentSeed = 1

Ken

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

"Omavlana Omav" <ki***@boardroo mlimited.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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.SqlCo mmand(mySql, gSQLConnection)
UsrAdapter = New SqlClient.SqlDa taAdapter(myCom mand)
myDataSet = New DataSet

Dim myDataTable As New DataTable("Shar eHoldersAuditRe port")
myDataSet.Table s.Add("ShareHol dersAuditReport ")
Dim aColumn As DataColumn
aColumn = myconstraint
aColumn = New DataColumn("aaa a")
myDataSet.Table s("ShareHolders AuditReport").C olumns.Add(aCol umn)
aColumn = New DataColumn("bbb b")
myDataSet.Table s("ShareHolders AuditReport").C olumns.Add(aCol umn)
aColumn = New DataColumn("ccc c")
myDataSet.Table s("ShareHolders AuditReport").C olumns.Add(aCol umn)
UsrAdapter.Fill (myDataSet, "ShareHoldersAu ditReport")
myTable = myDataSet.Table s("ShareHolders AuditReport")
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 AutoIncrementSe ed 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***@boardroo mlimited.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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.SqlCo mmand(mySql, gSQLConnection)
UsrAdapter = New SqlClient.SqlDa taAdapter(myCom mand)
myDataSet = New DataSet

Dim myDataTable As New DataTable("Shar eHoldersAuditRe port")
myDataSet.Table s.Add("ShareHol dersAuditReport ")
Dim aColumn As DataColumn
aColumn = myconstraint
aColumn = New DataColumn("aaa a")
myDataSet.Table s("ShareHolders AuditReport").C olumns.Add(aCol umn)
aColumn = New DataColumn("bbb b")
myDataSet.Table s("ShareHolders AuditReport").C olumns.Add(aCol umn)
aColumn = New DataColumn("ccc c")
myDataSet.Table s("ShareHolders AuditReport").C olumns.Add(aCol umn)
UsrAdapter.Fill (myDataSet, "ShareHoldersAu ditReport")
myTable = myDataSet.Table s("ShareHolders AuditReport")
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
5455
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) Child (ChildID, Name, ParentID)
6
6510
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 table, I have to use SCOPE_IDENTITY(). Any ideas? SqlConnection conn = new SqlConnection(connectionString); conn.Open(); //Create the dataadapter
2
5838
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; SqlCommandBuilder _builder; SqlConnection conn = new SqlConnection(GlobalSettings.ConnectionString);
3
6991
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 dataset. My current app is using sqlClient and a typed dataset that I created by exporting an xsd
3
3218
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 code below is simply trying to load an empty table that has only three columns. In the code I set the Name and Type fields. The third column is a unique primary key set to Integer. I have set the Primary Key to Identity with a seed of 1 and...
5
1695
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 several users that the directory it is in has, including IUSR_JASMINE (my system is named jasmine). Here is the weird part. In my aps .net code I have the following: String jname = Request.PhysicalApplicationPath + "images\\java_" + fileNum +...
0
1236
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", System.Type.GetType("System.Int32") ds.Tables("tbl1").Columns("tblID").AutoIncrement = True ds.Tables("tbl1").Columns("tblID").AutoIncrementSeed = 1
1
6898
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! Is this feature documented? Can i use it in production? I also noticed when using Access, AutoNumber field as ItemId, this feature
1
1839
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 this i have to write query string. I got dataset from table. and write ds.Tables.Columns.AutoIncrement
0
8443
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...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
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 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...
0
5663
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
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1772
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.