我已經做了幾個小時的研究,但似乎沒有什麼適用於我目前的情況。ExecuteReader:CommandText屬性尚未初始化
使用:Visual Studio 2010的.NET 4.0 語言:C#
問題:
我創建了一個表格,然後將它從我的數據源下降的特定表到形式有VS2010創建數據我的桌子。 當我嘗試使用數據表更改或向數據庫添加值時,出現上面列出的錯誤「ExecuteReader:CommandText屬性尚未初始化」。
從我以前的研究,不,我沒有定義CommandText,也不知道在哪裏創建一個考慮VS2010創建所有數據表的代碼,並沒有列出.cs文件本身。
感謝您的幫助!
代碼從形式擊中F7
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace mineral_monitor.Manual_edits
{
public partial class mineral_stock : Form
{
public mineral_stock()
{
InitializeComponent();
}
private void mineralsBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.mineralsBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.ore_stockDataSet1);
}
private void mineral_stock_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'ore_stockDataSet1.minerals' table. You can move, or remove it, as needed.
this.mineralsTableAdapter.Fill(this.ore_stockDataSet1.minerals);
}
}
}
此獲得的是通過在數據設計手動創建一個更新串解決。
CommandText = ????請發佈您的代碼.. CommandType = ??? – MethodMan 2012-02-14 15:09:09
將命令文本傳遞給命令對象是適配器的責任。因此,您可能無法使用適配器中的「SelectCommand」。 – 2012-02-14 15:49:16
@WiktorZychla - 當我在數據設計器中查看TableAdapter屬性時,它確實聲明它具有選擇,插入和更新命令。 – Sirusx69 2012-02-14 15:52:21