- Joined
- Nov 14, 2006
- Messages
- 2
- Reaction score
- 0
Hello, I am adding a record into SQL server via VB asp.net.
I want to retrieve the ID of the record just added.
Below is what i have thus far.
It runs, but I cannot figure out how to read or in fact get the ID.
Do note, I did not include all the the insert parameter call outs.
please help
SqlDataSource1.InsertParameters.Add("getID", TypeCode.Int16, 0)
SqlDataSource1.InsertParameters.Item("getID").Direction = ParameterDirection.InputOutput
SqlDataSource1.InsertCommand = "Insert into tblcustomer (txtname,txtaddress1,txtaddress2,txtcity,txtstate,areacode,txtphone,ext,txtzip,txtfax,txtcountry,intjde,intregion,deactivated) Values (@txtname,@txtaddress1,@txtaddress2,@txtcity,@txtstate,@areacode,@txtphone,@ext,@txtzip,@txtfax,@txtcountry,@intjde,@intregion,@deactivated);Set @getID = Scope_Identity();"
SqlDataSource1.Insert()
Response.Write("Test " & SqlDataSource1.InsertParameters.Item(14).DefaultValue.ToString)
I want to retrieve the ID of the record just added.
Below is what i have thus far.
It runs, but I cannot figure out how to read or in fact get the ID.
Do note, I did not include all the the insert parameter call outs.
please help
SqlDataSource1.InsertParameters.Add("getID", TypeCode.Int16, 0)
SqlDataSource1.InsertParameters.Item("getID").Direction = ParameterDirection.InputOutput
SqlDataSource1.InsertCommand = "Insert into tblcustomer (txtname,txtaddress1,txtaddress2,txtcity,txtstate,areacode,txtphone,ext,txtzip,txtfax,txtcountry,intjde,intregion,deactivated) Values (@txtname,@txtaddress1,@txtaddress2,@txtcity,@txtstate,@areacode,@txtphone,@ext,@txtzip,@txtfax,@txtcountry,@intjde,@intregion,@deactivated);Set @getID = Scope_Identity();"
SqlDataSource1.Insert()
Response.Write("Test " & SqlDataSource1.InsertParameters.Item(14).DefaultValue.ToString)