【发布时间】:2011-03-08 20:32:31
【问题描述】:
希望有人能对我的问题有所了解。我按照这里找到的教程http://msdn.microsoft.com/en-us/library/ms171925(v=VS.100).aspx#Y3500 并不能让它工作。
我的代码如下:
namespace CityCollectionCSharp
{
public partial class frmSwitch : Form
{
public frmSwitch()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'newCityCollectionDataSet.ClientTable' table. You can move, or remove it, as needed.
this.clientTableTableAdapter.Fill(this.newCityCollectionDataSet.ClientTable);
// TODO: This line of code loads data into the 'newCityCollectionDataSet.PropertyInformation' table. You can move, or remove it, as needed.
this.propertyInformationTableAdapter.Fill(this.newCityCollectionDataSet.PropertyInformation);
}
private void propertyInformationDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
System.Data.DataRowView SelectedRowView;
newCityCollectionDataSet.PropertyInformationRow SelectedRow;
SelectedRowView = (System.Data.DataRowView)propertyInformationBindingSource.Current;
SelectedRow = (newCityCollectionDataSet.PropertyInformationRow)SelectedRowView.Row;
frmSummary SummaryForm = new frmSummary();
SummaryForm.LoadCaseNumberKey(SelectedRow.CaseNumberKey);
SummaryForm.Show();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
propertyInformationBindingSource.Filter = "ClientKey ='" + comboBox1.SelectedValue + "'";
}
}
}
这是第一种形式,现在是第二种形式:
namespace CityCollectionCSharp
{
public partial class frmSummary : Form
{
public frmSummary()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'newCityCollectionDataSet.PropertyInformation' table. You can move, or remove it, as needed.
this.propertyInformationTableAdapter.Fill(this.newCityCollectionDataSet.PropertyInformation);
}
internal void LoadCaseNumberKey(String CaseNumber)
{
propertyInformationTableAdapter.FillByCaseNumberKey(newCityCollectionDataSet.PropertyInformation, CaseNumber);
}
}
}
我在 propertyInfromationTableAdapter 中设置了如下查询:
SELECT CaseNumberKey, BRTNumber, ParcelNumber, Premises, ClientKey, ParcelNum, Registry, TaxAcctName, StreetCode, CoverDate, OrderDate, Assessment, TaxFrom, TaxTo, TaxOpen, WaterOpen, WaterAcct, WaterTo, WaterFrom, AssessedBeg, AssessedDim, SumNotes, Legal, TotalWater, TotalTax, Type, OPARec, OPADoc, OPADocNum, Recital, Num, Name, Direction, Unit, ProductKey, DateFinished, Finished, Paid, BD, BDPaid, Search, Exam
FROM PropertyInformation
WHERE (CaseNumberKey = @CaseNumberKey)
我终其一生都无法弄清楚为什么这不能按规定工作。当我单击一条记录时,它会传递表中的两条记录,并且总是在我拥有的框中包含第一个记录。我只在离开绑定导航器时才知道这一点。任何帮助将不胜感激。
【问题讨论】:
标签: c# sql datagridview