0
我加載一個DataTable到DataGrid視圖通過調用下面的函數:VB.NET數據表列類型
Public Sub GetData(ByVal selectCommand As String, ByVal bindingSource As BindingSource, ByVal table As DataTable)
Try
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\adm\Desktop\222.mdb"
Me.dataAdapter = New OleDbDataAdapter(selectCommand, connectionString)
Dim commandBuilder As New OleDbCommandBuilder(Me.dataAdapter)
table.Locale = System.Globalization.CultureInfo.InvariantCulture
Me.dataAdapter.Fill(table)
bindingSource.DataSource = table
Catch ex As OleDbException
MessageBox.Show(ex.Message)
End Try
End Sub
這裏是函數調用:
GetData("select * from products where ID=1 or ID=2", bindingSource1, t1)
現在,確實數據表定義來自源數據庫的列類型? 因爲當我嘗試將數據添加到DateTime列時,它說該列是整數類型,但在Access中,我可以看到它是一個DateTime列。那麼我需要爲每一列指定每種類型還是自動完成?
這是一個類型數據集? – 2012-08-12 15:53:18
t1是一個Datatable – user1590636 2012-08-12 15:55:26