Hi,
I have to create a temp table to store data from a table in it using stored procedure and then retrive it from the code.
I need to save the data in the begining before it is deleted.And then after the inserts are done I want to update the tblcontactlist by referring to the temp table.
Can someone help me with this please?
Code:
Private Sub btnAssign_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAssign.Click
Dim bUpdate As Boolean = True
Try
Dim strSql As String
Dim strSql1 As String
Dim dr As SqlDataReader
'delete exist Employees
strSql = "delete from tblBNIContactList where companyid=" & txtCompanyid.Text
da.UpdateData(strSql)
'Assign Employee
Dim i As Integer
For i = 0 To lbxSelectedEmployees.Items.Count - 1
strSql = "insert into tblContactList(CompanyID, IssuePrefix, UserID, PM, DevMgr, AltIncAllCorr) values("
strSql &= cboCompanyName.SelectedValue & ",'" & txtIssuePrefix.Text & "', '" & lbxSelectedEmployees.Items(i).Value & "', 0, 0, 0)"
da.UpdateData(strSql)
Next
'Assign PM
If cboPM.SelectedValue <> "" Then
strSql = "update tblContactList set PM=1 where CompanyID=" & cboCompanyName.SelectedValue & " and UserID='" & cboPM.SelectedValue & "'"
da.UpdateData(strSql)
End If
'Assign DM
For i = 0 To lbxDM.Items.Count - 1
If lbxDM.Items(i).Selected = True Then
strSql = "update tblContactList set DevMgr=1 where CompanyID=" & cboCompanyName.SelectedValue & " and UserID='" & lbxDM.Items(i).Value & "'"
da.UpdateData(strSql)
End If
Next
'Assign QA
For i = 0 To lbxQA.Items.Count - 1
If lbxQA.Items(i).Selected = True Then
strSql = "update tblContactList set AltIncAllCorr=1 where CompanyID=" & cboCompanyName.SelectedValue & " and UserID='" & lbxQA.Items(i).Value & "'"
da.UpdateData(strSql)
End If
Next
'Update Nocorr values for critical issues
If nocorrvalue.Count <> 0 Then
strSql = "update tblbnicontactlist set nocorr=1 where userid in(nocorrvalue)"
End If
_dbAccess.dbAccess.GetConnection.Close()
_dbAccess.dbAccess.GetConnection.Dispose()
Catch ex As System.Exception
_dbAccess.dbAccess.GetConnection.Close()
_dbAccess.dbAccess.GetConnection.Dispose()
bUpdate = False