A
Alex Shirley
Hi
I'm using ASP.Net (VS2003). I think this is more an ADO Question. I've
just deleted a row from a dataset and I want to update the database
from the recently altered dataset. It's not working.... Can you skim
down the code, look at the comments below please?
Many thanks
Alex
'
'SqlDeleteProducts
'
Me.SqlDeleteProducts.CommandText = "DELETE FROM [Products Assigned to
Contacts] WHERE (ProductContactID = @ProductContactID)"
Me.SqlDeleteProducts.Connection = Me.SqlConnection1
Me.SqlDeleteProducts.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@ProductContactID",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "ProductContactID",
System.Data.DataRowVersion.Original, Nothing))
CType(Me.DsContactsX1,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DsContactIndex1,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DsProductsAssignedToContacts1,
System.ComponentModel.ISupportInitialize).EndInit()
''''''''''''''''''
'Find position in dataset
Dim rowDelete As DSProductsAssignedToContacts.Products_Assigned_to_ContactsRowrowDelete
= DsProductsAssignedToContacts1.Products_Assigned_to_Contacts.FindByProduct_ProductContactID(e.Item.Cells(2).Text)
' Find position in dataset
rowDelete.Delete()
DGProducts.DataBind() ' This works so far, row has now visibliy
deleted from my datagrid DGProducts
'From here downwards it doesn't work, I am merely trying to update the
' database from the dataset
'I get error "Prepared statement '(@ProductContactID int)DELETE FROM
'[Products Assigned to Contact' expects parameter @ProductContactID,
'which was not supplied."
'It seems to ignore the very next line,
'I've tried chopping it out and it doesn't work either.
'I'm supplying the correct parameter aren't I?
SqlDeleteProducts.Parameters("@ProductContactID").Value =
CInt(e.Item.Cells(2).Text.ToString)
DAProductsAssignedToContacts.Update(DsProductsAssignedToContacts1)
Please help!
Thanks
Alex
I'm using ASP.Net (VS2003). I think this is more an ADO Question. I've
just deleted a row from a dataset and I want to update the database
from the recently altered dataset. It's not working.... Can you skim
down the code, look at the comments below please?
Many thanks
Alex
'
'SqlDeleteProducts
'
Me.SqlDeleteProducts.CommandText = "DELETE FROM [Products Assigned to
Contacts] WHERE (ProductContactID = @ProductContactID)"
Me.SqlDeleteProducts.Connection = Me.SqlConnection1
Me.SqlDeleteProducts.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@ProductContactID",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "ProductContactID",
System.Data.DataRowVersion.Original, Nothing))
CType(Me.DsContactsX1,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DsContactIndex1,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DsProductsAssignedToContacts1,
System.ComponentModel.ISupportInitialize).EndInit()
''''''''''''''''''
'Find position in dataset
Dim rowDelete As DSProductsAssignedToContacts.Products_Assigned_to_ContactsRowrowDelete
= DsProductsAssignedToContacts1.Products_Assigned_to_Contacts.FindByProduct_ProductContactID(e.Item.Cells(2).Text)
' Find position in dataset
rowDelete.Delete()
DGProducts.DataBind() ' This works so far, row has now visibliy
deleted from my datagrid DGProducts
'From here downwards it doesn't work, I am merely trying to update the
' database from the dataset
'I get error "Prepared statement '(@ProductContactID int)DELETE FROM
'[Products Assigned to Contact' expects parameter @ProductContactID,
'which was not supplied."
'It seems to ignore the very next line,
'I've tried chopping it out and it doesn't work either.
'I'm supplying the correct parameter aren't I?
SqlDeleteProducts.Parameters("@ProductContactID").Value =
CInt(e.Item.Cells(2).Text.ToString)
DAProductsAssignedToContacts.Update(DsProductsAssignedToContacts1)
Please help!
Thanks
Alex