无法绑定到数据源上的 属性 或列。 vb.net
Cannot bind to the property or column on the DataSource. vb.net
我有错误无法绑定到 属性 或列,请解决。笔记我用的是studio visuals 2010,请问有什么好的方案或者推荐吗?
谢谢
杰克
Dim Path As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim cn As String = "provider=Microsoft.Jet.OLEDB.4.0; data source=" & Path & "; Extended Properties=dBase IV"
Dim WithEvents bmb As BindingManagerBase
Dim dsTest As New DataSet
Private Sub CreateDataSetfillgridview()
Try
Dim query As String = "select EMPLOYEEN,HIREDATE FROM TRIAL"
Using con As OleDbConnection = New OleDbConnection(cn)
Using cmd As OleDbCommand = New OleDbCommand(CStr(query), con)
Using da As New OleDbDataAdapter(cmd)
Dim dt As DataTable = New DataTable()
da.Fill(dt)
dsTest.Tables.Add(dt)
End Using
End Using
End Using
'Bind controls
DataGrid1.DataSource = dsTest
'if I comment the code below then a dataset appears as screenshot below
Me.TextBox1.DataBindings.Add("Text", dsTest, "EMPLOYEEN")
Dim MyBinding As New Binding("Value", dsTest, "HIREDATE")
AddHandler MyBinding.Format, AddressOf dtFormatter
AddHandler MyBinding.Parse, AddressOf dtParser
DateTimePicker1.DataBindings.Add(MyBinding)
'Force a Refresh of bound controls
bmb = Me.BindingContext(dsTest, "TRIAL")
bmb.Position = bmb.Count
bmb.Position = 0
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
End Try
End Sub
感谢@CaiusJard 的指导
Dim Path As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim cn As String = "provider=Microsoft.Jet.OLEDB.4.0; data source=" & Path & "; Extended Properties=dBase IV"
Dim WithEvents bmb As BindingManagerBase
Dim dsTest As New DataSet
Private Sub CreateDataSetfillgridview()
Try
Dim query As String = "select EMPLOYEEN,HIREDATE FROM TRIAL"
Using con As OleDbConnection = New OleDbConnection(cn)
Using cmd As OleDbCommand = New OleDbCommand(CStr(query), con)
Using da As New OleDbDataAdapter(cmd)
Dim dt As DataTable = New DataTable("TRIAL")
da.Fill(dt)
dsTest.Tables.Add(dt)
End Using
End Using
End Using
'Bind controls
DataGrid1.DataSource = dsTest.Tables("TRIAL")
Me.TextBox1.DataBindings.Add("Text", dsTest, "TRIAL.EMPLOYEEN")
Dim MyBinding As New Binding("Value", dsTest, "TRIAL.HIREDATE")
AddHandler MyBinding.Format, AddressOf dtFormatter
AddHandler MyBinding.Parse, AddressOf dtParser
DateTimePicker1.DataBindings.Add(MyBinding)
'Force a Refresh of bound controls
bmb = Me.BindingContext(dsTest, "TRIAL")
bmb.Position = bmb.Count
bmb.Position = 0
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
End Try
End Sub
我有错误无法绑定到 属性 或列,请解决。笔记我用的是studio visuals 2010,请问有什么好的方案或者推荐吗?
谢谢 杰克
Dim Path As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim cn As String = "provider=Microsoft.Jet.OLEDB.4.0; data source=" & Path & "; Extended Properties=dBase IV"
Dim WithEvents bmb As BindingManagerBase
Dim dsTest As New DataSet
Private Sub CreateDataSetfillgridview()
Try
Dim query As String = "select EMPLOYEEN,HIREDATE FROM TRIAL"
Using con As OleDbConnection = New OleDbConnection(cn)
Using cmd As OleDbCommand = New OleDbCommand(CStr(query), con)
Using da As New OleDbDataAdapter(cmd)
Dim dt As DataTable = New DataTable()
da.Fill(dt)
dsTest.Tables.Add(dt)
End Using
End Using
End Using
'Bind controls
DataGrid1.DataSource = dsTest
'if I comment the code below then a dataset appears as screenshot below
Me.TextBox1.DataBindings.Add("Text", dsTest, "EMPLOYEEN")
Dim MyBinding As New Binding("Value", dsTest, "HIREDATE")
AddHandler MyBinding.Format, AddressOf dtFormatter
AddHandler MyBinding.Parse, AddressOf dtParser
DateTimePicker1.DataBindings.Add(MyBinding)
'Force a Refresh of bound controls
bmb = Me.BindingContext(dsTest, "TRIAL")
bmb.Position = bmb.Count
bmb.Position = 0
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
End Try
End Sub
感谢@CaiusJard 的指导
Dim Path As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim cn As String = "provider=Microsoft.Jet.OLEDB.4.0; data source=" & Path & "; Extended Properties=dBase IV"
Dim WithEvents bmb As BindingManagerBase
Dim dsTest As New DataSet
Private Sub CreateDataSetfillgridview()
Try
Dim query As String = "select EMPLOYEEN,HIREDATE FROM TRIAL"
Using con As OleDbConnection = New OleDbConnection(cn)
Using cmd As OleDbCommand = New OleDbCommand(CStr(query), con)
Using da As New OleDbDataAdapter(cmd)
Dim dt As DataTable = New DataTable("TRIAL")
da.Fill(dt)
dsTest.Tables.Add(dt)
End Using
End Using
End Using
'Bind controls
DataGrid1.DataSource = dsTest.Tables("TRIAL")
Me.TextBox1.DataBindings.Add("Text", dsTest, "TRIAL.EMPLOYEEN")
Dim MyBinding As New Binding("Value", dsTest, "TRIAL.HIREDATE")
AddHandler MyBinding.Format, AddressOf dtFormatter
AddHandler MyBinding.Parse, AddressOf dtParser
DateTimePicker1.DataBindings.Add(MyBinding)
'Force a Refresh of bound controls
bmb = Me.BindingContext(dsTest, "TRIAL")
bmb.Position = bmb.Count
bmb.Position = 0
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
End Try
End Sub