EB.*_*EB. 1 c# sql database datagridview
我正在尝试将数据网格存档到数据表中,以便我可以在存档日期的表格中找到它.我使用INSERT SQL语句如下:
INSERT INTO [VendorArchive] ([Booth], [Deposit], [Rent], [Electric], [Security],
[AmountPaid], [DatePaid], [PeriodPaid], [TotalDue], [Notes], [ArchiveDate],
[BalanceDue], GETDATE());
SELECT Booth, Deposit, Rent, Electric, Security AmountPaid, DatePaid, PeriodPaid,
TotalDue, BalanceDue, Notes
FROM Vendors
Run Code Online (Sandbox Code Playgroud)
然后我在我的代码中调用按钮单击事件中的sql函数:
private void vendorArchiveToolStripButton_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure you wish to archive?", "Perform Archive", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
vendorArchiveTableAdapter.PerformArchive();
MessageBox.Show("Archive has completed.");
}
}
Run Code Online (Sandbox Code Playgroud)
当我调试并点击归档按钮时,我收到此错误:"方法'没有重载'PerformArchive'接受0参数"
我不明白.我使用错误的SQL语句吗?我是否需要在方法调用中将所有列添加为argumnets?
请帮忙.
您的SQL查询错误,但您获得的具体错误与您的SQL查询无关.
在项目的某个地方,您有一个调用的方法PerformArchive
,此方法至少需要一个参数.您需要为该参数提供值.
假设您使用的是Visual Studio,请将光标放在方法名称上,然后按F12转到定义,然后您可以看到参数是什么.
关于你的SQL你需要这样的东西:
INSERT INTO [VendorArchive] (
[Booth], [Deposit], [Rent], [Electric], [Security], [AmountPaid], [DatePaid], [PeriodPaid], [TotalDue], [BalanceDue], [Notes], [ArchiveDate]
)
SELECT
[Booth], [Deposit], [Rent], [Electric], [Security], [AmountPaid], [DatePaid], [PeriodPaid], [TotalDue], [BalanceDue], [Notes], GETDATE()
FROM Vendors
Run Code Online (Sandbox Code Playgroud)
我修正的错误:
Security
和之间添加了缺少的逗号AmountPaid
. 归档时间: |
|
查看次数: |
127 次 |
最近记录: |