•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 423,451 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,730 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 1604 | Replies: 5
![]() |
•
•
Join Date: Sep 2006
Posts: 45
Reputation:
Rep Power: 3
Solved Threads: 0
I splitted the two updates.
I am trying to update one table with new user entered values
It is working fine
The problem now is with the second update, where I am trying to update some file names values into the table through listbox
here i have two listboxes, in listbox1, i have some filenames, which i can add or remove from listbox2
problem is that the file names are not getting updated.
Suppose the user chooses file1, file2, from listbox1, add to lisbox2 and then update, it is not getting updated.
i am inserting the listbox1.item.value along with the contactid.
Public Sub UpdateAccounts(ByVal contactid As Int32)
Dim userBll As UserCreationBLL = New UserCreationBLL()
Dim listitems As Int32 = lstAllAccounts.Items.Count
Dim lstItems As Int32 = lstAccountAccess.Items.Count
If (lstItems > 0) Then
Dim i As Int16
For i = 0 To lstItems - 1
userBll.UpdateAccounts(contactid, Convert.ToInt32(lstAccountAccess.Items(i).Value))
Next i
End If
End Sub
SP for updating is
ALTER PROCEDURE UpdateAccounts
@contactID int,
@accountID int
AS
UPDATE [Contact Account ]
SET [Account ID] = @accountID
WHERE [Contact ID] = @contactID
thanks
I am trying to update one table with new user entered values
It is working fine
The problem now is with the second update, where I am trying to update some file names values into the table through listbox
here i have two listboxes, in listbox1, i have some filenames, which i can add or remove from listbox2
problem is that the file names are not getting updated.
Suppose the user chooses file1, file2, from listbox1, add to lisbox2 and then update, it is not getting updated.
i am inserting the listbox1.item.value along with the contactid.
Public Sub UpdateAccounts(ByVal contactid As Int32)
Dim userBll As UserCreationBLL = New UserCreationBLL()
Dim listitems As Int32 = lstAllAccounts.Items.Count
Dim lstItems As Int32 = lstAccountAccess.Items.Count
If (lstItems > 0) Then
Dim i As Int16
For i = 0 To lstItems - 1
userBll.UpdateAccounts(contactid, Convert.ToInt32(lstAccountAccess.Items(i).Value))
Next i
End If
End Sub
SP for updating is
ALTER PROCEDURE UpdateAccounts
@contactID int,
@accountID int
AS
UPDATE [Contact Account ]
SET [Account ID] = @accountID
WHERE [Contact ID] = @contactID
thanks
•
•
Join Date: Oct 2005
Location: Manchester, UK
Posts: 482
Reputation:
Rep Power: 3
Solved Threads: 33
ALTER PROCEDURE UpdateAccounts @contactID int, @accountID int AS begin transaction UPDATE [Contact Account ] SET [Account ID] = @accountID WHERE [Contact ID] = @contactID UPDATE [Other table] SET [Account ID] = @accountID WHERE [Contact ID] = @contactId commit transaction
Note to self... pocket cup
•
•
Join Date: Sep 2006
Posts: 45
Reputation:
Rep Power: 3
Solved Threads: 0
Thanks
But now i am not using two updates in a single one
I separated two updates in 2 diff SP
First one is working
second one for Updating accounts
If i add some files from listbox1 to listbox2, it is getting updated
if i remove some files from listbox2, and then update, it is not updating
how can i check for the removed items in listbox
SP i am using is
ALTER PROCEDURE UpdateAccounts
@contactID int,
@accountID int
AS
INSERT INTO [Contact Account ]([Contact ID],[Account ID])
sELECT @accountid, @contactid
WHERE NOT EXISTS (SELECT 'X' FROM [dbo].[Contact Account ]
WHERE [Account ID] = @accountid AND
[contact id] = @contactid)
But now i am not using two updates in a single one
I separated two updates in 2 diff SP
First one is working
second one for Updating accounts
If i add some files from listbox1 to listbox2, it is getting updated
if i remove some files from listbox2, and then update, it is not updating
how can i check for the removed items in listbox
SP i am using is
ALTER PROCEDURE UpdateAccounts
@contactID int,
@accountID int
AS
INSERT INTO [Contact Account ]([Contact ID],[Account ID])
sELECT @accountid, @contactid
WHERE NOT EXISTS (SELECT 'X' FROM [dbo].[Contact Account ]
WHERE [Account ID] = @accountid AND
[contact id] = @contactid)
![]() |
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- So Lost writing this program... (C++)
- TableAdapter Update Method (VB.NET)
- USING CLASSES in VB6 (Visual Basic 4 / 5 / 6)
- Error connecting to database (ASP.NET)
Other Threads in the MS SQL Forum
- Previous Thread: Problems with my sql server version
- Next Thread: How to design the history table to be more efficient?


Linear Mode