【发布时间】:2019-05-17 22:19:42
【问题描述】:
大家好,我需要在我的标签上显示我的数据库中的单词,但我遇到了一个问题,它对我不起作用并且它没有显示单词... 我正在使用 Select from 并且它没有显示它......
string connectionStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\WordssTable.mdb;
Persist Security Info=False";
OleDbConnection connectObj = new OleDbConnection(connectionStr);
connectObj.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connectObj;
command.CommandText = "SELECT * FROM WordsTable WHERE EnglishWord='" + hebw1.Text + "'";
command.ExecuteNonQuery();
2
<form runat="server">
<div id = "Words">
<asp:Label runat="server" id="Engw"></asp:Label>
<br />
<asp:Label id="hebw1" runat="server"></asp:Label>
<asp:Label id="hebw2" runat="server"></asp:Label>
<asp:Label id="hebw3" runat="server"></asp:Label>
<asp:Label id="hebw4" runat="server"></asp:Label>
</div>
</form>
【问题讨论】:
-
您的样本不完整。你执行命令了吗?您是否使用 OleDbDataReader 返回的数据来更新您的标签?请发帖minimal reproducible example 帮助我们了解您的问题
-
兄弟我要补充什么?
-
您可能需要考虑a DataSource control,因为您正在使用网络表单。链接的文档主要演示了使用 MS SQL Server,但差别很小。