Torna al Thread

Dim Connection As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydb.mdb;Jet OLEDB:Database Password=password") Dim Command As New OleDb.OleDbCommand Dim ds As New Dataset Dim da As New OleDb.OleDbDataAdapter Dim row As System.Data.DataRow Dim Count As Integer Connection.Open() 'open up a connection to the database Command.Connection = Connection da.SelectCommand = New OleDb.OleDbCommand("SELECT * FROM Table1", Connection) da.Fill(ds, "Table") 'Fill the dataset, ds, with the above SELECT statement Count = ds.Tables("Table").Rows.Count While Count > -1 'loop through for each row, add it to the datagridview row = ds.Tables("Table").Rows.Item(Count) Datagridview.rows.add(row.Item(0)) Count = Count - 1 End While Connection.Close()
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5