Vertragsverwaltung-Klassenbibliothek  

MyDocMgmt.Save_Document -Methode

Dokument in der Tabelle Dokument speichern

[Visual Basic]
Public Function Save_Document( _ 
ByVal Dokumentnr As Integer, _ 
ByVal Filename As String
) As Boolean

Parameter

Dokumentnr
Nummer des Dokument-Datensatzes
Filename
Zu speichender Dateiname

Quellcode

[Visual Basic]
        Public Function Save_Document(ByVal Dokumentnr As Integer, ByVal Filename As String) As Boolean 
Dim Connection As New SqlConnection() 
Dim DA As New SqlDataAdapter("select * from dokument where dokumentnr =" + Str(dokumentnr), Connection) 
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(DA) 
Dim ds As New DataSet() 
Dim fs As New FileStream(filename, FileMode.OpenOrCreate, FileAccess.Read) 
Dim mydata(fs.Length) As Byte 
fs.Read(mydata, 0, fs.Length) 
fs.Close() 
Try 
Connection.ConnectionString = Globals.sConnectionString 
Connection.Open() 
DA.Fill(ds, "Dokument") 
Dim myRow As DataRow 
If ds.Tables(0).Rows.Count = 0 Then 
Return False 
Else 
myRow = ds.Tables(0).Rows(0) 
myRow.Item(16) = mydata 
DA.Update(ds, "Dokument") 
End If 
Catch ex As Exception 
MsgBox(ex.Message) 
Return False 
End Try 
fs = Nothing 
cb = Nothing 
ds = Nothing 
DA = Nothing 
Connection.Close() 
Connection = Nothing 
Return True 
End Function

Forderungen

Plattformen: Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

Siehe auch

MyDocMgmt