Hi All,

I have this code in vb.net and what I want to do is move the code into a stored procedure in SQL Server. Basically, all the code does is loop through records in one table and insert the records from that table into another table. Pretty simple... Not sure how to do that in SQL Server and also call the stored procedure from vb.net. I would have to feed the date in from vb.net into the stored procedure.

Any help would be appreciated!

Code from vb.net below:

da = New SqlClient.SqlDataAdapter("SELECT * FROM vwPeople Where MemberStatus <> 'Former Member' OR MemberStatus <> 'Inactive Member' Order By LastName Asc", SqlConn)
da.Fill(ds, "GETPERSONS1")

Dim i As Integer = 0

While i <= ds.Tables("GETPERSONS1").Rows.Count - 1
Dim name As String
name = u.FTM(ds.Tables("GETPERSONS1").Rows(i).Item("LastName")) + " " + u.FTM(ds.Tables("GETPERSONS1").Rows(i).Item("FirstName"))
u.ExecuteSQL(SqlConn, "INSERT INTO tblContributionsN (PeopleID, ContributionDate, Name, Amount, Code, GivingType, EnvelopeNumber, Household, CheckNumber, ContribType, Service, Description) values ('" & Val(ds.Tables("GETPERSONS1").Rows(i).Item("RecordId")) & "', '" & Format(Me.dtWorshipDate.Value, "MM/dd/yyyy") & "', '" & name & "', '0', '1-General Fund', '', '" & Val(ds.Tables("GETPERSONS1").Rows(i).Item("EnvelopeNumber")) & "','" & u.FTM(ds.Tables("GETPERSONS1").Rows(i).Item("Household")) & "', '', 'Regular', '', '')")

i = i + 1
End While

At the end of the SP, I would want to return something to vb.net telling me it was done.