Hello,
vb.net /MSDE question
I have a form to add a new record.When Save buttton is pushed,the
record is saved to the database,but i don't know how to
get the new id back in my dataset (instead of -1)
the rowupdated event more specific :
e.row("id") =.... throws an error : 'column 'id' is readonly'
I know id is readonly.but i in the past i used the same code(except
@@identity instead of ident_current)
with access databases and everthing worked fine.
here's the code i used
da = New SqlDataAdapter( command)
da.FillSchema(d s, SchemaType.Sour ce, "gegevens")
ds.Tables("gege vens").Columns( "id").AutoIncre mentSeed = -1
ds.Tables("gege vens").Columns( "id").AutoIncre mentStep = -1
da.Fill(ds, "gegevens")
dv = ds.Tables("gege vens").DefaultV iew
cmb = New SqlCommandBuild er(da)
cm = CType(Me.Bindin gContext(dv), CurrencyManager )
Private Sub da_RowUpdated(B yVal sender As Object, ByVal e As
System.Data.Sql Client.SqlRowUp datedEventArgs) Handles da.RowUpdated
If e.Status = UpdateStatus.Co ntinue AndAlso (e.StatementTyp e =
StatementType.I nsert) Then
Dim cmdnieuwnr As New SqlCommand("SEL ECT
IDENT_CURRENT(' dat_test')", cn)
e.Row("id") = CType(cmdnieuwn r.ExecuteScalar , Integer)
e.Row.AcceptCha nges()
End I
End Sub
any help apreciated,look ing for the answer for 2 days now
Kind regards,
Stefan
vb.net /MSDE question
I have a form to add a new record.When Save buttton is pushed,the
record is saved to the database,but i don't know how to
get the new id back in my dataset (instead of -1)
the rowupdated event more specific :
e.row("id") =.... throws an error : 'column 'id' is readonly'
I know id is readonly.but i in the past i used the same code(except
@@identity instead of ident_current)
with access databases and everthing worked fine.
here's the code i used
da = New SqlDataAdapter( command)
da.FillSchema(d s, SchemaType.Sour ce, "gegevens")
ds.Tables("gege vens").Columns( "id").AutoIncre mentSeed = -1
ds.Tables("gege vens").Columns( "id").AutoIncre mentStep = -1
da.Fill(ds, "gegevens")
dv = ds.Tables("gege vens").DefaultV iew
cmb = New SqlCommandBuild er(da)
cm = CType(Me.Bindin gContext(dv), CurrencyManager )
Private Sub da_RowUpdated(B yVal sender As Object, ByVal e As
System.Data.Sql Client.SqlRowUp datedEventArgs) Handles da.RowUpdated
If e.Status = UpdateStatus.Co ntinue AndAlso (e.StatementTyp e =
StatementType.I nsert) Then
Dim cmdnieuwnr As New SqlCommand("SEL ECT
IDENT_CURRENT(' dat_test')", cn)
e.Row("id") = CType(cmdnieuwn r.ExecuteScalar , Integer)
e.Row.AcceptCha nges()
End I
End Sub
any help apreciated,look ing for the answer for 2 days now
Kind regards,
Stefan
Comment