C#和SQL不起作用,对此非常新. -如果您查看此内容,但没有发现任何错误,可以请您回答. [英] C# & SQL Not working, very new to this. - If you look at this and can see nothing wrong, can you please put that as an answer.
问题描述
您好,由于需要更好的条款,我无法将数据发送到"Stick".我将项目剥离到以下代码行.当我运行此按钮时,使用调试工具,按下按钮将添加10条记录,我可以看到数据集每次增加10条记录.但是,一旦关闭程序,所有数据都会消失,如果再次运行它,我将再次从0开始添加10的块.它是名为ProjectA的数据库中的单个表.我在说一些真的,真的是基本的东西还是我有一个更大的问题?
Hello, I am having problems getting my data to "Stick" for want of a better term. I''ve stripped back my project to the following lines of code. When I run this the pressing of the button adds 10 records, using debug tools, I can see the dataset grow by 10 records each time. Once I close the program though, all the data disappears, and if I run it again I start adding blocks of 10 from 0 again. It''s a single table in a database called ProjectA. Am I mssing something really, really basic or do I have a bigger problem?
namespace ProjectA
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ProjectADataSetTableAdapters.tblCurrenciesTableAdapter curr = new ProjectA.ProjectADataSetTableAdapters.tblCurrenciesTableAdapter();
ProjectADataSet.tblCurrenciesDataTable ds = new ProjectADataSet.tblCurrenciesDataTable();
curr.Fill(ds);
for (int i = 0; i < 10; i++)
{
ProjectADataSet.tblCurrenciesRow newRow = ds.NewtblCurrenciesRow();
newRow.fldCurrencyID = "A" + i;
newRow.fldCurrencyDescription = "AAAA" + i;
ds.AddtblCurrenciesRow(newRow);
}
curr.Update(ds);
}
}
}
推荐答案
检查此更新的
Hi ,
Check this Updated
private void button1_Click(object sender, EventArgs e)
{
WindowsFormsApplication32.DataSet1TableAdapters.ProductTableAdapter adpt = new DataSet1TableAdapters.ProductTableAdapter();
DataSet1 ds = new DataSet1();
adpt.Fill(ds.Product);
for (int i = 0; i < 10; i++)
{
DataSet1.ProductRow newRow= ds.Product.NewProductRow();
newRow.name = "A" + i;
ds.Product.AddProductRow(newRow);
}
adpt.Update(ds.Product);
ds.AcceptChanges();
}
最好的问候
米特瓦里(M.Mitwalli)
Best Regards
M.Mitwalli
这篇关于C#和SQL不起作用,对此非常新. -如果您查看此内容,但没有发现任何错误,可以请您回答.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!