L
Lucas Bussey
To start, I'm using VB 2005 and SQL Server Express 2005.
This almost appears to be a bug, but I've yet to find an actual bug and
generally narrow my issues down to user-error on my part. I have the
following code snippet (LogFile is a class I've created simply to output to
a textfile):
---
Dim ta As New mattersTableAdapter
Dim dt As New mattersDataTable
Dim dr As mattersRow
LogFile.WriteLine("Adding new matter...")
'Fill data table
ta.Fill(dt)
'Add new data row and update
dr = dt.NewmattersRow
dr.Item("file_no") = "New Matter"
dr.Item("date_created") = Now
dr.Item("date_modified") = Now
dt.AddmattersRow(dr)
ta.Update(dt)
dt.AcceptChanges()
LogFile.WriteLine("New matter added. Id: {0}.",
dr.Item("m_id").ToString)
---
As you can probably already tell I'm using a Strongly Typed Dataset. The
table schema includes "m_id" being the Primary Key and has the property
"Identity Specification" set to Yes and increments by 1.
My issue is that if the DataTable is empty after being filled from the
database (ie: the database table is empty) I get 0 (zero) returned to "m_id"
in the DataRow. If the DataTable already contains existing records and I run
this code, I get the appropriate, incremented value.
Is there something I'm missing?
Thanks in advance for any help...
Luke
This almost appears to be a bug, but I've yet to find an actual bug and
generally narrow my issues down to user-error on my part. I have the
following code snippet (LogFile is a class I've created simply to output to
a textfile):
---
Dim ta As New mattersTableAdapter
Dim dt As New mattersDataTable
Dim dr As mattersRow
LogFile.WriteLine("Adding new matter...")
'Fill data table
ta.Fill(dt)
'Add new data row and update
dr = dt.NewmattersRow
dr.Item("file_no") = "New Matter"
dr.Item("date_created") = Now
dr.Item("date_modified") = Now
dt.AddmattersRow(dr)
ta.Update(dt)
dt.AcceptChanges()
LogFile.WriteLine("New matter added. Id: {0}.",
dr.Item("m_id").ToString)
---
As you can probably already tell I'm using a Strongly Typed Dataset. The
table schema includes "m_id" being the Primary Key and has the property
"Identity Specification" set to Yes and increments by 1.
My issue is that if the DataTable is empty after being filled from the
database (ie: the database table is empty) I get 0 (zero) returned to "m_id"
in the DataRow. If the DataTable already contains existing records and I run
this code, I get the appropriate, incremented value.
Is there something I'm missing?
Thanks in advance for any help...
Luke