VS2017 / EF6不支持向数据绑定到datagridview的向导是否有这样的VISUAL BASIC示例? [英] VS2017/EF6 does not support wizard to databind to datagridview Is there a VISUAL BASIC example of this ?
问题描述
我正在使用VS2017并尝试从我从数据库创建的EntityDataSource填充datagridview但是我收到一条错误,说该向导只与EF5兼容并通过编辑标记页来配置控件。
I'm using VS2017 and trying to populate a datagridview from an EntityDataSource which I have created from a database but I get an error saying the wizard is only compatible with EF5 and to configure the control by editing the markup page.
有这方面的例子吗?我假设我需要一些代码来创建EntityDataSource并且我使用Visual Basic。
Is there an example of this? I assume I need some code to create the EntityDataSource and I am using Visual Basic.
如果有一个步骤,这将非常有用。
If there is a walk through this would be very helpful.
我读过的一个说明是,微软不鼓励使用Entity Framework。这是真的,如果有的话有什么选择?
One note I read said that Microsoft discouraged using Entity Framework for this. IS this true and if so what are the alternatives?
推荐答案
嗨David Millsom ,
欢迎来到MSDN论坛。
根据您的要求,我建议您使用ADO.NET。这是一个示例代码:
Imports System.Data.SqlClient
Public Class Form1
Dim constr As String = "Data Source = (localdb)\MSSQLLocalDB; Integrated Security = True ;AttachDbFileName= C:\Users\alexl2\Desktop\DataBase\Alex\alex.mdf"
Dim conn As SqlConnection
Dim sda As SqlDataAdapter
Dim dt As DataTable
Dim bind As New BindingSource
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Using conn = New SqlConnection(constr)
conn.Open()
sda = New SqlDataAdapter("Select * From Student", conn)
dt = New DataTable()
sda.Fill(dt)
DataGridview1.Datasource=dt
End Using
End Sub
End Class
关于ADO.NET的更多细节,请看看:
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet / 。
And about more detail of ADO.NET, please have a look : https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ .
最好的问候。
可能
这篇关于VS2017 / EF6不支持向数据绑定到datagridview的向导是否有这样的VISUAL BASIC示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!