Prev: Split cells VBA
Next: rounding to nearest .5 in vba
From: JackD on 3 Mar 2010 08:21 Hi all, I am using OWC11 (AxSpreadsheet) control in my vb.net application. In that i need to display data from Mysql DB. This is my sample code to bind data to spreadsheet. AxSpreadsheet2.Worksheets(1).Cells.Clear() AxSpreadsheet2.Worksheets(1).Name = "Batches" AxSpreadsheet2.Worksheets(1).StandardWidth = 15 cmd.CommandText = "SELECT * FROM `TableName`" cmd.Connection = connect If connect.State = ConnectionState.Closed Then connect.Open() Dim da As New MySqlClient.MySqlDataAdapter Dim ds As New DataSet da = New MySqlClient.MySqlDataAdapter(cmd) da.Fill(ds) ProgressBar1.Value = 0 ProgressBar1.Maximum = ds.Tables(0).Rows.Count k = 1 For ro As Integer = 0 To ds.Tables(0).Rows.Count - 1 k += 1 For cl As Integer = 0 To ds.Tables(0).Columns.Count - 1 AxSpreadsheet2.Worksheets(1).Cells(k, cl + 1) = ds.Tables(0).Rows(ro).Item(cl).ToString Next ProgressBar1.Value += 1 Next But it was very slow. It is possible to use Axspreadsheet.Datasource method to bind the dataset values. Pls guide me.
|
Pages: 1 Prev: Split cells VBA Next: rounding to nearest .5 in vba |