'1
'the function
Public Shared Function InsertNewRecord(ByVal myStoredProcedure As String) As Boolean
Dim conn As New SqlConnection
conn = MyFormz.connec.ConnWeb2()
Dim cmdInsert As New SqlCommand
Dim sSQL As New String("")
Dim iSqlStatus As Integer
sSQL = myStoredProcedure
cmdInsert.Parameters.Clear()
Try
With cmdInsert
.CommandText = sSQL 'Your sql statement
.CommandType = CommandType.StoredProcedure
'.Parameters.AddWithValue("@value1", item1)
'.Parameters.AddWithValue("@value2", item2)
'.Parameters.AddWithValue("@value3", item3)
'Set the connection of the object
.Connection = conn
End With
conn.Open()
'Set the iSqlStatus to the ExecuteNonQuery
'status of the insert (0 = success, 1 = failed)
iSqlStatus = cmdInsert.ExecuteNonQuery
If Not iSqlStatus = 0 Then
Return False
Else
Return True
End If
Catch ex As Exception
Finally
conn.Close()
End Try
End Function
'2
'the code to call the function
Dim obj As ClassClass = New ClassClass
ClassClass.InsertNewRecord("udp_tblArea_ups")
'obj.InsertNewRecord = New
obj.InsertNewRecord = New inse
i have a function that i have in my data access class now i want to access it then declare and assign parameters and then insert data into database can someone help.any help would be appreciated