从插入形式的数据到数据集 [英] Insert data from forms into datasets

查看:190
本文介绍了从插入形式的数据到数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集设置了3场,ID的用户名和密码。我希望用户输入一个新的用户名和passoword,这对当时被保存回数据集。我如何采取什么已被键入,并保存到数据集?

I have a dataset set up with 3 fields, ID username and password. I want the user to type in a new username and passoword and this then gets saved back to the dataset. How do I take what has been typed in and save it into the data set?

到目前为止,这是在code我有

So far this is the code I have

usersTableAdapters.UsersTableAdapter user = new usersTableAdapters.UsersTableAdapter();
user.usersDataTable usertable = user.GetData();

这让我连接到数据集,虽然我不知道如何利用用户将在输入框中输入值和将其保存到数据集?

This allows me to connect to the data set although I am not sure how to take the values the user will enter in the input boxes and save them back to the dataset?

推荐答案

一个快速和肮脏的实施,这将是这样的:

A quick and dirty implementation of this would look like this:

DataSet ds = new DataSet();
ds.Tables.Add(textBox1.Text);  //I did this in Winforms so, your result may vary.
ds.Tables.Add(textBox2.Text);  //Same here.

if (ds.HasChanges())  //Check if the DataSet has changes.
   ds.AcceptChanges(); //If it does, commit them.

这篇关于从插入形式的数据到数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆