Grid-Layoutfile speichern
[Visual Basic] Public Function Save_LayoutFile( _
ByRef c1data As C1TrueDBGrid, _
ByVal GridNo As Integer, _
ByVal Profilnr As Integer _
) As Boolean
[Visual Basic] Public Function Save_LayoutFile(ByRef c1data As C1TrueDBGrid, ByVal GridNo As Integer, ByVal Profilnr As Integer) As Boolean
Dim filename As String = Globals.clsapplication.sTmp_filepath + Trim(Str(Profilnr)) + Trim(Str(GridNo)) + ".lyt"
c1data.SaveLayout(filename)
Dim Connection As New SqlConnection()
Dim DA As New SqlDataAdapter("select * from profil where profilnr = " & Str(Profilnr), Connection)
'mitarbeiternr=" + Str(Globals.clsmitarbeiter.iMitarbeiternr.Value)
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, "profil")
Dim myRow As DataRow
If ds.Tables(0).Rows.Count = 0 Then
' Neues Profil sepeichern
myRow = ds.Tables(0).NewRow
myRow.Item(1) = Globals.clsmitarbeiter.iMitarbeiternr.Value
myRow.Item(2) = ""
Select Case GridNo
Case 1
myRow.Item(3) = mydata
End Select
ds.Tables(0).Rows.Add(myRow)
DA.Update(ds, "profil")
Else
myRow = ds.Tables(0).Rows(0)
Select Case GridNo
Case 1
myRow.Item(3) = mydata
End Select
DA.Update(ds, "profil")
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
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