Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
|
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 18th, 2010, 02:22 PM
Registered User
 
Join Date: Nov 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using temp table to store and retrieve data

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
store procedure, temp table kumiko SQL Language 2 January 15th, 2008 05:46 AM
Retrieve different data from same table /field W052107 Visual Studio 2005 7 August 6th, 2007 10:40 AM
Retrieve data from word table Paul_Tic Access VBA 2 May 26th, 2006 11:31 AM
How to retrieve data from an array to a table? penta Access 4 September 22nd, 2004 03:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.