OLEDB alle Datensätze durchlaufen

05/02/2009 - 08:42 von Andreas Ahrens | Report spam
Hi NG,

wie muß ich den Code àndern, um alle Datensàtze zu durchlaufen?


'Auswahl Tabelle und Felder
Private selStr As String = "SELECT * FROM Kunden"

'ACCESS-Datenbank
Private connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0.0;" & _
"Data Source=IT-Projekt.mdb"

'SQL-Datenbank
Private connStr1 As String = "Provider=SQLOLEDB.1;Data
Source=.\SQLEXPRESS;" & _
"Initial Catalog = 'Datenbank';" & _
"Integrated Security=SSPI"

Private connStr2 As String = "Provider=SQLNCLI;Server=.\SQLEXPRESS;" & _
"Database=myDataBase;Uid=root"
'Pwd=myPassword;"

Private conn As OleDbConnection
Private da As OleDbDataAdapter
Private dt As DataTable
Private cb As OleDbCommandBuilder
Private bm As BindingManagerBase
Private tn As TreeNode

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
conn = New OleDbConnection(connStr)
da = New OleDbDataAdapter(selStr, conn)
dt = New DataTable("Kunden")

cb = New OleDbCommandBuilder(da)

cb.QuotePrefix = "["
cb.QuoteSuffix = "]"

conn.Open()
da.Fill(dt)

conn.Close()

'Steuerelemente mit Daten verbinden
'Databindings.Add("Datentyp", DataTable, "Datenfeld")
Me.ComboBox1.DataBindings.Add("Text", dt, "Anrede")
Me.TextBox1.DataBindings.Add("Text", dt, "NName")
Me.TextBox2.DataBindings.Add("Text", dt, "VName")
Me.TextBox3.DataBindings.Add("Text", dt, "Straße")
Me.TextBox4.DataBindings.Add("Text", dt, "Plz")
Me.TextBox5.DataBindings.Add("Text", dt, "Ort")
Me.RichTextBox1.DataBindings.Add("Text", dt, "Bwmerkung")

bm = Me.BindingContext(dt)

Me.ComboBox1.Select()
Dim i As Integer

For i = 0 To bm.Count
Me.TreeView1.Nodes.Add(dt)
Next

Guss
Andy
 

Lesen sie die antworten

#1 Helmut Woess
05/02/2009 - 14:11 | Warnen spam
Am Wed, 4 Feb 2009 23:42:05 -0800 schrieb Andreas Ahrens:
...
For i = 0 To bm.Count
Me.TreeView1.Nodes.Add(dt)
Next



Bin kein Access-Anwender, aber müsste da vor dem "Next" (der Schleife)
nicht sowas wie dt.Next oder dt.NextRow stehen?

bye,
Helmut

Ähnliche fragen