【问题标题】:Add new Data source in Visual Studio 2019 Faild在 Visual Studio 2019 中添加新数据源失败
【发布时间】:2021-06-16 15:16:18
【问题描述】:

我正在使用 VS 2019 并想在我的项目中添加一个新的数据源。我的项目很简单,只想添加新的数据源但出现以下错误。

"所选项目不支持此窗口。启用数据绑定的步骤请访问

https://docs.microsoft.com/en-us/dotnet/desktop/winforms/windows-forms-data-binding?view=netframeworkdesktop-4.8

" 我不知道该怎么办。我错过了什么吗?请帮我解决这个问题。 在此先感谢:)

【问题讨论】:

  • 可以分享代码吗?
  • 我认为不需要共享代码。它与代码无关。我不能只从 Project-> 添加新数据源添加新数据源。得到上面提到的错误。
  • private void addbtn_Click(object sender, EventArgs e) { string conStr = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString; SqlConnection con = new SqlConnection(conStr); con.Open(); SqlCommand 命令 = 新 SqlCommand(); command.Connection = con; command.CommandText = "插入测试表值('"+textBox1.Text+"')"; command.ExecuteNonQuery(); con.Close();计数++;获取索引——; }

标签: c# winforms datasource


【解决方案1】:

您使用“.Net Core”项目吗?似乎数据绑定选项仅适用于“.NET Framework”Windows 窗体项目,不适用于 .NET Core Windows 窗体项目。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-15
    • 1970-01-01
    • 2020-10-14
    • 2021-08-10
    • 1970-01-01
    • 2020-12-21
    相关资源
    最近更新 更多