M
mrmgroups
Hi,
I am really new to this so please be gentle. I have a web page (aspx)
that is a simple form. The info is filled in and a stored procedure
updates the table. The table updates as expected no issues there.
What I am trying to do is get back the identity value(table field is
auto incrementing integer) for the record that has been updated. EG I
update the table it creates a new record with the id of 25 the 25 is
the value I am trying to get. Below is the test code I am using while
trying to sort this out (the actual page is the same just has more
parameters that are passed). Any help and pointers in the right
direction will be very much appreciated.
Thanks
Mark
------- Start of Code -----
Public Partial Class test
Inherits System.Web.UI.Page
Protected Sub submitButton_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles submitButton.Click
Dim TestDataSource As New SqlDataSource()
Dim cb1 As String
TestDataSource.ConnectionString =
ConfigurationManager.ConnectionStrings("WebEmployConnectionString1").ToString()
TestDataSource.InsertCommandType =
SqlDataSourceCommandType.StoredProcedure
TestDataSource.InsertCommand = "TestInsert"
TestDataSource.InsertParameters.Add("Name1",
Name1TextBox.Text)
Dim Birthdate As DateTime =
Convert.ToDateTime(Name2TextBox.Text)
TestDataSource.InsertParameters.Add("Name2",
TypeCode.DateTime, Birthdate)
TestDataSource.InsertParameters.Add("text1",
text1TextBox.Text)
TestDataSource.InsertParameters.Add("text2",
text2TextBox.Text)
If CheckBox1.Checked Then
cb1 = "checkedxxxx"
Else
cb1 = ""
End If
TestDataSource.InsertParameters.Add("text3", cb1)
TestDataSource.InsertParameters.Add("AppNo", 0)
Dim rowsAffected As Integer = 0
Try
rowsAffected = TestDataSource.Insert()
Catch ex As Exception
Server.Transfer("error.htm")
Finally
TestDataSource = Nothing
End Try
If rowsAffected < 1 Then
Server.Transfer("error2.htm")
Else
Server.Transfer("ok.htm")
End If
End Sub
End Class
----- End of Code -----
I am really new to this so please be gentle. I have a web page (aspx)
that is a simple form. The info is filled in and a stored procedure
updates the table. The table updates as expected no issues there.
What I am trying to do is get back the identity value(table field is
auto incrementing integer) for the record that has been updated. EG I
update the table it creates a new record with the id of 25 the 25 is
the value I am trying to get. Below is the test code I am using while
trying to sort this out (the actual page is the same just has more
parameters that are passed). Any help and pointers in the right
direction will be very much appreciated.
Thanks
Mark
------- Start of Code -----
Public Partial Class test
Inherits System.Web.UI.Page
Protected Sub submitButton_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles submitButton.Click
Dim TestDataSource As New SqlDataSource()
Dim cb1 As String
TestDataSource.ConnectionString =
ConfigurationManager.ConnectionStrings("WebEmployConnectionString1").ToString()
TestDataSource.InsertCommandType =
SqlDataSourceCommandType.StoredProcedure
TestDataSource.InsertCommand = "TestInsert"
TestDataSource.InsertParameters.Add("Name1",
Name1TextBox.Text)
Dim Birthdate As DateTime =
Convert.ToDateTime(Name2TextBox.Text)
TestDataSource.InsertParameters.Add("Name2",
TypeCode.DateTime, Birthdate)
TestDataSource.InsertParameters.Add("text1",
text1TextBox.Text)
TestDataSource.InsertParameters.Add("text2",
text2TextBox.Text)
If CheckBox1.Checked Then
cb1 = "checkedxxxx"
Else
cb1 = ""
End If
TestDataSource.InsertParameters.Add("text3", cb1)
TestDataSource.InsertParameters.Add("AppNo", 0)
Dim rowsAffected As Integer = 0
Try
rowsAffected = TestDataSource.Insert()
Catch ex As Exception
Server.Transfer("error.htm")
Finally
TestDataSource = Nothing
End Try
If rowsAffected < 1 Then
Server.Transfer("error2.htm")
Else
Server.Transfer("ok.htm")
End If
End Sub
End Class
----- End of Code -----