Graphik fonts

Werbung
-------------------------------------------------------------------------------------Dim myConnect As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Firma.mdb;" '
auf Schreibweise von Data Source achten (LZ) !!!
Dim mySelectQuery = "SELECT * FROM Kunden"
Dim myConn As New OleDbConnection(myConnect)
Dim myDataAdapter As New OleDbDataAdapter()
Dim myDataSet As New DataSet()
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Dim custCB As New OleDbCommandBuilder(myDataAdapter)
' automatisches
Generieren der UPDATE-Anweisung
myDataAdapter.SelectCommand = New OleDbCommand(mySelectQuery, myConn) ' SQLAbfrage zuweisen
myDataAdapter.Fill(myDataSet, "Customers") ' Ausführen der SQL-Abfrage
(Anlegen und Füllen der Tabelle "Customers" im Dataset)
' Anbinden des DataGrid an Dataset:
DataGrid1.DataSource = myDataSet
DataGrid1.DataMember = "Customers"
' oder einfacher:
' DataGrid1.SetDataBinding(myDataSet, "Customers")
myConn.Close()
End Sub
' Update gestaltet sich wegen OleDbCommandBuilder einfach
'( funktioniert aber nur, wenn mind. eine Spalte der Kunden-Tabelle indiziert ist,
' bzw. Prim‫ن‬rschlüssel hat):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
myDataAdapter.Update(myDataSet, "Customers")
' ge‫ن‬nderte Daten werden vom
Dataset in Datenbank übertragen
myConn.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Close()
End Sub
End Class
Graphik fonts
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
FontDialog1.Font = Label1.Font
If FontDialog1.ShowDialog Then
Label1.Font = FontDialog1.Font
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
ColorDialog1.AllowFullOpen = False
ColorDialog1.CustomColors = New Integer() {6975964, 231202, 1294476}
If ColorDialog1.ShowDialog = DialogResult.OK Then
Me.BackColor() = ColorDialog1.Color
End If
End Sub
End Class
Sql
Dim conn As SqlConnection
Dim ds As DataSet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim conStr As String = "Data Source=(local); Initial Catalog=Northwind;" _
& "Integrated Security=True"
conn = New SqlConnection(conStr)
conn.Open()
ds = New DataSet()
Dim selStr As String = "SELECT * FROM Customers WHERE City = 'London'"
Dim da As New SqlDataAdapter(selStr, conn)
da.Fill(ds, "LondonCustomers")
conn.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim dt As DataTable = ds.Tables.Item("LondonCustomers")
Dim custRow As DataRow
ListBox1.Items.Clear()
For Each custRow In dt.Rows
ListBox1.Items.Add(custRow.Item("CompanyName"))
Next
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Sql-xsd-dataset
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim connStr As String = "Data Source=(local); Initial Catalog=Northwind;
Integrated Security=True"
Dim conn As New SqlConnection(connStr)
conn.Open()
Dim selStr As String = "SELECT * FROM Customers WHERE City='Berlin'"
Dim da As New SqlDataAdapter(selStr, conn)
Dim ds As New DataSet("KundenDataSet")
da.Fill(ds, "Kunden")
conn.Close()
ds.WriteXmlSchema("c:\KundenDataSet.xsd")
' evtl. Pfad anpassen
End Sub
' Die generierte XSD-Schema-Datei muss mit dem Tool xsd.exe umgewandelt werden:
xsd /d /l:VB KundenDataSet.xsd
' Es entsteht die Klassendatei "KundenDataSet.vb", die dem VB-Projekt hinzuzufügen
ist.
' Die Klasse KundenDataSet hat strukturspezifische Eigenschaften (z.B.
.Kunden(i).Firma, s.u.) !!!
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim conn As SqlConnection
Dim conStr As String = "Data Source=(local); Initial Catalog=Northwind;
Integrated Security=True"
conn = New SqlConnection(conStr)
conn.Open()
Dim ds As New KundenDataSet()
Dim selStr As String = "SELECT * FROM Customers WHERE City = 'London'"
Dim da As New SqlDataAdapter(selStr, conn)
da.Fill(ds, "Kunden")
conn.Close()
ListBox1.Items.Clear()
Dim i As Integer
For i = 0 To ds.Kunden.Count - 1
'ListBox1.Items.Add(ds.Kunden(i).CompanyName)
' strukturabh‫ن‬ngige
Eigenschaft!
ListBox1.Items.Add(ds.Kunden(i).ContactName)
Next
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
End Class
Messagebox
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
MessageBox.Show("Meldungstext", "Kopfzeile", MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
MessageBox.Show("Meldungstext", "Kopfzeile", MessageBoxButtons.YesNo,
MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
MessageBox.Show("Meldungstext", "Kopfzeile", MessageBoxButtons.YesNo,
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
MessageBox.Show("Meldungstext", "Kopfzeile", MessageBoxButtons.YesNo,
MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
MessageBox.Show("Meldungstext", "Kopfzeile", MessageBoxButtons.YesNo,
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
MessageBox.Show("Meldungstext", "Kopfzeile", MessageBoxButtons.YesNo,
MessageBoxIcon.None, MessageBoxDefaultButton.Button1)
MessageBox.Show("Meldungstext", "Kopfzeile", MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
MessageBox.Show("Meldungstext", "Kopfzeile", MessageBoxButtons.YesNo,
MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
MessageBox.Show("Meldungstext", "Kopfzeile", MessageBoxButtons.YesNo,
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Select Case MessageBox.Show("Achtung! Ihre Festplatte wird formatiert!",
"Kleiner Hinweis", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question)
Case DialogResult.Abort
' Abbruch
Case DialogResult.Retry
' Wiederholen
Case DialogResult.Ignore
' Ignorieren
End Select
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
End Sub
End Class
Herunterladen