Creating identity column in a datatable

  • Thread starter Thread starter Omavlana Omav
  • Start date Start date
O

Omavlana Omav

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.
 
I don't think that's the proper way to do it.

When your print function is called, you get one page size.
So when your data print module is created, you get a huge list from
the database to write out.

Then when it's time to write you keep an index of where in the huge
data list you are. Each time you draw a line, you increase a value
keeping track of the y position as well as index.
When the y position is larger than the page size, you set has more
pages to true and stop printing lines.
Your print code will now be called again, and your index will tell you
where to begin printing next. Your y position should be reset hear or
be a local variable in the print function.

Hope it makes any sense

Odin
 
Back
Top