From: Patrick A on 7 Apr 2010 13:16 All, I am trying to make some (Drag and Drop re-order) code work. I have learned that it will not work with a data-bound DataGridView. So I deleted my old data-bound DataGridView, and added a new DataGridView to my form, and filled it using the code below. Here's the dumb question - is this still considered a data-bound DataGridView? This may be semantics, but if it is still considered data-bound, I'll stop trying to get the code to work (aka beating my head on my keyboard). Thanks, Patrick *********** Private Sub sfrmSetupButtons_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cnString As String 'Set up connection string as String Dim sqlQRYRows As String 'Set up sqlQuery string as String 'Define the connection string cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H: \L55Timer\L55Timer.mdb;Jet OLEDB:database Locking Mode=0;Mode=Share Deny None" sqlQRYRows = "Select * from QRY_Buttons" 'Build the command text conn = New OleDbConnection(cnString) ' Set up conn as a connection Try conn.Open() ' Open the connection da = New OleDbDataAdapter(sqlQRYRows, conn) 'Set up the Data Adapter 'create command builder Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(da) 'fill dataset ds.Clear() da.Fill(ds, "Buttons") Me.DataGridView1.DataMember = "Buttons" Catch ex As OleDbException MsgBox(ex.ToString) Finally ' Close connection Me.DataGridView1.RowsDefaultCellStyle.BackColor = Color.LightBlue Me.DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray Me.DataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True Me.DataGridView1.DataSource = ds DataGridView1.Columns(0).Visible = False conn.Close() End Try End Sub
|
Pages: 1 Prev: Using Data Stored on External Drives in 64 bit computer Next: pregunta de principiante.. |