Sub Routine to a Function

LadyGail

Newcomer
Joined
May 5, 2003
Messages
13
I have a sub routine that works. I would like to change it to a function so that I can call the method of the function from the code behind file for the insert sql string to populate the db.

The data for the insert if coming from two textboxes.

I thank you.

Lady

My sub routine looks like the following:

Sub btnNewDivision_Click(s As Object, e As EventArgs)
Dim conn As SqlConnection
Dim cmdInsert As SqlCommand
Dim strInsert As String

conn = New SqlConnection("data source=S0960028;initial catalog=POWER;user id=gu;password=wasdall")
strInsert = "INSERT DivisionCode ( DivCode, DivName ) Values (@DivCode, @DivisionName )"
cmdInsert = New SqlCommand(strInsert, conn)
cmdInsert.Parameters.Add("@DivCode", txtDivCode.Text)
cmdInsert.Parameters.Add("@DivisionName", txtDivisionName.Text)
conn.Open()
cmdInsert.ExecuteNonQuery()
conn.Close()

End Sub

The code behind file:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dim newinsert as clDivision

If not ispostback then
newinsert.methodfromfunction(????)
End If

End Sub
 
Back
Top