gpt4 book ai didi

c# - 无效的对象名称(即使存在)

转载 作者:行者123 更新时间:2023-12-03 08:11:26 25 4
gpt4 key购买 nike

这是我的代码:

   InitializeComponent();
SqlConnection myConnection = new SqlConnection("data source = DESKTOP-77FA1JE;" +
"user id = DESKTOP-77FA1JE\\Chanloi" +
"initial catalog = TransactionProcessingSystem;" +
"integrated security = SSPI");

myConnection.Open();

SqlCommand myCommand = new SqlCommand("select * from UserAccounts", myConnection);
SqlDataReader myReader = myCommand.ExecuteReader();

BindingSource mySource = new BindingSource();
mySource.DataSource = myReader;

dataGridView1.DataSource = mySource;

myConnection.Close();

我收到此错误:

System.Data.SqlClient.SqlException: 'Invalid object name 'UserAccounts'.'

最佳答案

非常简单-您的数据库中没有名为UserAccounts的表。
请尝试dbo.UserAccounts

关于c# - 无效的对象名称(即使存在),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42712144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com