Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TableAdapter insert record - help please?

Status
Not open for further replies.

SJG0526

Programmer
Jul 5, 2002
108
US
I am using a strongly typed dataset and have filled the table adapter like so:
Code:
Me.TblOrderTableAdapter.Fill(Me.DS_OrderLookup.tblOrder, "OrderUID < 0")
giving me tblOrder table in my dataset with no records (since none will have OrderUID < 0).

I'm using the following SQL stored proc (Order__Insert) for inserting a record:
Code:
ALTER PROCEDURE dbo.Order__Insert
(
	@OrderNumber int,
	@OrderTypeUID int,
	@ManufacturerUID int,
	@SoldTo int,
	@Company nvarchar(30),
	@ShipTo int,
	@Attention nvarchar(20)
)
AS
	SET NOCOUNT OFF;
INSERT INTO [tblOrder] ([OrderNumber], [OrderTypeUID], [ManufacturerUID], [SoldTo], [Company], [ShipTo], [Attention]) VALUES (@OrderNumber, @OrderTypeUID, @ManufacturerUID, @SoldTo, @Company, @ShipTo, @Attention);
	
SELECT OrderUID, OrderNumber, OrderTypeUID, ManufacturerUID, SoldTo, Company, ShipTo, Attention FROM tblOrder WHERE (OrderUID = @@SCOPE_IDENTITY)
Now I want to add a record into tblOrder so I do this:
Code:
Dim r1 As DS_OrderLookup.tblOrderRow

r1 = Me.DS_OrderLookup.tblOrder.NewtblOrderRow   'add a new blank row
With r1
     .OrderUID = 0
     .OrderNumber = iNextNo
     .OrderDate = Now()
     .Company = "ABC Corporation"
End With
Me.DS_OrderLookup.tblOrder.AddtblOrderRow(r1)
Dim x As Int16 = Me.TblOrderTableAdapter.Update(Me.DS_OrderLookup.tblOrder)
I get an error saying
Procedure or function 'Order__Insert' expects parameter '@OrderNumber', which was not supplied
Can anyone please help me with this? Thanks!
 
Why do you want to use the sp to add the order? The table adapter already has that functionality. If you are going to use the sp, then you need to supply the values of the parameters in the format: exec Order__Insert 'p1', 'p2', etc. in the execute method. And you will need to supply all seven parms, as you don't declare any default values for them.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top