Solved

Transfer Recordset from one table to another tableu using SQL 2000 and VB.net

Posted on 2009-07-15
2
258 Views
Last Modified: 2012-05-07
I have 2 views based on 3 tables.
Event table
Particpant Table
Attendance table

Vparticipants (View) has two fields in each row
EventID and ParticipantID
the VParticipants may have 1-20 records in the dataset

vAttendance (view) has EventId and ParticpantID in each row.


I have to transfer the vparticipants recordset with each EventID and ParticpantID
to the  EventID and ParticipantID fields in the Attendance Table using the vAttendance(view)

I would like to do this action on a button click using VB.net and SQL.
I am still learning about stored procedures so if there is a way I can do this in VB.net
and inline SQL code on the button click . That would speed it up for me.

I am using asp.net VB.net and SQL server 2000
0
Comment
Question by:tommynations
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
drypz earned 500 total points
ID: 24866236
Hi! Try this one
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim validConnectionString As String = "Your valid connection string here"
        Dim sqlInsertCommand As String = "INSERT INTO Attendance (EventID,ParticpantID) SELECT EventID,ParticpantID FROM vAttendance"
        Dim sqlConnection As SqlConnection = New SqlConnection(validConnectionString)
        Dim sqlCommand As SqlCommand = New SqlCommand(sqlInsertCommand, sqlConnection)
        sqlCommand.CommandType = Data.CommandType.Text
        sqlConnection.Open()
        sqlCommand.ExecuteNonQuery()
        sqlConnection.Close()
 
    End Sub

Open in new window

0
 

Author Comment

by:tommynations
ID: 24868775
Thanks DRYPZ. This looks like what I need.
I might not have explained the scenario correctly.
I will put this code in the code behind on the form Attendance.
I want to transfer the recordset based on the eventID from VParticipants.
I do not need to use the vAttendance (view ) at all
It seems like I need to grab the EventID in vParticpants and Transfer the recordset from vParticipants.
Am I correct and  What changes do I need to make in the code you have provided to accomplish this .?
THanks for responding
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question