PC Review


Reply
Thread Tools Rate Thread

Createing identity column in datatable

 
 
Omavlana Omav
Guest
Posts: n/a
 
      13th Oct 2003


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").Columns.Add(aColumn)
aColumn = New DataColumn("bbbb")
myDataSet.Tables("ShareHoldersAuditReport").Columns.Add(aColumn)
aColumn = New DataColumn("cccc")
myDataSet.Tables("ShareHoldersAuditReport").Columns.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!
 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      13th Oct 2003
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").AutoIncrementSeed = 1

Ken

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

"Omavlana Omav" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
>
> 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").Columns.Add(aColumn)
> aColumn = New DataColumn("bbbb")
> myDataSet.Tables("ShareHoldersAuditReport").Columns.Add(aColumn)
> aColumn = New DataColumn("cccc")
> myDataSet.Tables("ShareHoldersAuditReport").Columns.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!



 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      13th Oct 2003
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
>
> 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").Columns.Add(aColumn)
> aColumn = New DataColumn("bbbb")
> myDataSet.Tables("ShareHoldersAuditReport").Columns.Add(aColumn)
> aColumn = New DataColumn("cccc")
> myDataSet.Tables("ShareHoldersAuditReport").Columns.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!



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding identity column to an existing DataTable SoftLion Microsoft ADO .NET 1 30th Mar 2007 05:30 PM
Bug adding identity column to an existing DataTable SoftLion Microsoft Dot NET Framework 0 30th Mar 2007 08:29 AM
Updating Identity Column in datatable =?Utf-8?B?R2FyeQ==?= Microsoft ADO .NET 1 9th May 2004 04:08 AM
Creating an identity column in a datatable Omavlana Omav Microsoft Dot NET Compact Framework 1 13th Oct 2003 11:59 AM
Creating identity column in a datatable Omavlana Omav Microsoft Dot NET Framework Forms 1 13th Oct 2003 10:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:44 AM.