Imports DatabaseLibrary.DBLuokat Public Class clsPerus Private _strSQL As String = String.Empty Private _strConnection As String = String.Empty Private _intAvainID As Integer = -1 Private _strAvainKentta As String = String.Empty Private _strTaulu As String = String.Empty Private _strPolku As String = String.Empty Private _dtComboTaulu As New DataTable Public Sub New() Try ' Me.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & _ 'Me.Polku & "glossary.mdb;Persis Security Info=False;" 'ConfigurationSettings.AppSettings("glossary") Catch ex As Exception End Try End Sub Public Property strSQL() As String Get Return _strSQL End Get Set(ByVal Value As String) _strSQL = Value End Set End Property Public Property Polku() As String Get Return _strPolku End Get Set(ByVal Value As String) _strPolku = Value End Set End Property Public Property ConnectionString() As String Get 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Samples.mdb" ' "Provider=microsoft.jet.oledb.4.0;Data Source=C:\InetPub\wwwroot\glossary\database\glossary.mdb;Persist Security Info=False;" Return "Provider=microsoft.jet.oledb.4.0;Data Source=" & Me.Polku & ";Persist Security Info=False;" '_strConnection End Get Set(ByVal Value As String) _strConnection = Value End Set End Property Public Property AvainID() As Integer Get Return _intAvainID End Get Set(ByVal Value As Integer) _intAvainID = Value End Set End Property Public Property AvainKentta() As String Get Return _strAvainKentta End Get Set(ByVal Value As String) _strAvainKentta = Value End Set End Property Public Property Taulu() As String Get Return _strTaulu End Get Set(ByVal Value As String) _strTaulu = Value End Set End Property Public Sub Poista() Dim obDS As New clsDB_OleDb Try If Me.AvainID > 0 AndAlso Me.AvainKentta <> String.Empty AndAlso Me.Taulu <> String.Empty Then Else Err.Raise(1) End If Me.strSQL = "delete from " & Me.Taulu & " where " & Me.AvainKentta & "=" & Me.AvainID obDS.ConnectionString = Me.ConnectionString obDS.OpenDBConnection() obDS.ExecuteNonQuery(Me.strSQL) obDS.CloseDBConnection() obDS.Dispose() obDS = Nothing Catch ex As Exception When Err.Number = 1 If Not IsNothing(obDS) Then obDS.CloseDBConnection() obDS.Dispose() obDS = Nothing End If Throw New Exception("Valitse ensin poistettava!!") Catch ex As Exception If Not IsNothing(obDS) Then obDS.CloseDBConnection() obDS.Dispose() obDS = Nothing End If Throw New Exception("Poisto epäonnistui!!") End Try End Sub Private Sub MuodostaTaulu() Try _dtComboTaulu.Columns.Add("intID", Type.GetType("System.Int32")) _dtComboTaulu.Columns.Add("strOtsikko", Type.GetType("System.String")) Catch ex As Exception End Try End Sub Public ReadOnly Property PalautaTaulu() As DataTable Get If _dtComboTaulu.Columns.Count = 0 Then Me.MuodostaTaulu() End If Return _dtComboTaulu End Get End Property End Class